Actions

Difference between revisions of "カスタマイズ/テーマ/SmartyとDwooの違い"

From Mahara Wiki

< カスタマイズ/テーマ
(Created page with "作成中です - ~~~ Mahara 1.2 uses Dwoo instead of Smarty, as its templating engine. While there is considerable compatibility between the two engines, there are some things…")
 
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
作成中です - [[User:Mits|mits]]
+
Mahara 1.2ではテンプレートエンジンとして、Smartyの代わりにDwooを使用します。両テンプレートエンジンには多くの互換性がありますが、既存のテンプレートにおいて、変更すべき点がいくつかあります。
  
Mahara 1.2 uses Dwoo instead of Smarty, as its templating engine.  While there is considerable compatibility between the two engines, there are some things that will need to be changed in existing templates.
+
Mahara 1.2以降、私たちは「Smarty互換」構文を使用する代わりに、さらにDwooネイティブ構文へ移行します。しかし、少なくとも1.3では下位互換性を保持します。
 
 
Note that after 1.2, we will more and more move to Dwoo native syntax, rather than using the "Smarty compatible" syntax, but we'll keep backwards compatibility for 1.3 at least.
 
  
 
<div id="section_1">
 
<div id="section_1">
Line 9: Line 7:
 
===Cycle===
 
===Cycle===
  
In Smarty, {cycle} arguments don't need to be quoted. In Dwoo, they must be.  For example, {cycle values=r0,r1} works in Smarty, but must be changed to {cycle values='r0,r1} in Dwoo.
+
Smartyにおいて {cycle} 引数は引用符で囲む必要はありません。Dwooでは引用符で囲む必要があります。例えば、{cycle values=r0,r1} はSmartyで動作しますが、Dwooでは {cycle values='r0,r1} に変更する必要があります。
  
 
</div><div id="section_2">
 
</div><div id="section_2">
Line 15: Line 13:
 
===Insert===
 
===Insert===
  
Insert is used in Smarty to insert the return value of a function call, and skip caching.  Eg {insert name="messages"} would call the php function insert_messages, and insert what it returned into the resulting template.
+
Smartyにおいて、insertは関数呼び出しの戻り値を渡してキャッシングをスキップするために使用されます。例えば、{insert name="messages"} では、PHP関数 insert_messages をコールして、結果的に表示されるテンプレートに戻り値を渡します。
 
+
Dwooでは、これはネイティブのPHPコール {insert_messages} にて実現されます。そして、キャッシングをバイパスするため、{dynamic}{insert_messages}{/dynamic} のように {dynamic} タグで囲みます。
In Dwoo, this should be done using a native php call {insert_messages} and to bypass caching, be wrapped inside {dynamic} tags, like {dynamic}{insert_messages}{/dynamic}
 
  
 
</div><div id="section_3">
 
</div><div id="section_3">
  
===Use of "data" when including templates===
+
===テンプレートをインクルードする場合、 "データ" を使用する===
  
Both Smarty and Dwoo support including templates from within other templates, using {include}, and both support passing data between templates, using {include something='something'}.  However, if you pass a variable called "data" in Dwoo, it will overwrite the existing data, because of naming collision.  Therefore {include file='something.tpl' innerdata=$foo} must be used instead.
+
SmartyおよびDwooの両者とも {include} を使用して、他のテンプレートのインクルードをサポートします。同時に {include something='something'} を使用して、両者ともテンプレート間でのデータ受け渡しをサポートします。しかし、あなたがDwooにおいて、"data" という名称の変数を渡した場合、ネーミングの衝突により、既存のデータは上書きされてしまいます。そのため、代わりに {include file='something.tpl' innerdata=$foo} を使用すべきです。
  
 
</div><div id="section_4">
 
</div><div id="section_4">
Line 29: Line 26:
 
===Section===
 
===Section===
  
In some places in Mahara 1.1, we were using {section} instead of Loops.  This is really not properly compatible with Dwoo, it makes much more sense to just switch to a loop instead.
+
Mahara 1.1において、私たちはループの代わりに {section} を使用しています。これは全くDwooとは互換性がないため、代わりにループにスイッチする方が理に適ってます
  
 
</div>
 
</div>

Latest revision as of 04:04, 20 June 2011

Mahara 1.2ではテンプレートエンジンとして、Smartyの代わりにDwooを使用します。両テンプレートエンジンには多くの互換性がありますが、既存のテンプレートにおいて、変更すべき点がいくつかあります。

Mahara 1.2以降、私たちは「Smarty互換」構文を使用する代わりに、さらにDwooネイティブ構文へ移行します。しかし、少なくとも1.3では下位互換性を保持します。

Cycle

Smartyにおいて {cycle} 引数は引用符で囲む必要はありません。Dwooでは引用符で囲む必要があります。例えば、{cycle values=r0,r1} はSmartyで動作しますが、Dwooでは {cycle values='r0,r1} に変更する必要があります。

Insert

Smartyにおいて、insertは関数呼び出しの戻り値を渡してキャッシングをスキップするために使用されます。例えば、{insert name="messages"} では、PHP関数 insert_messages をコールして、結果的に表示されるテンプレートに戻り値を渡します。 Dwooでは、これはネイティブのPHPコール {insert_messages} にて実現されます。そして、キャッシングをバイパスするため、{dynamic}{insert_messages}{/dynamic} のように {dynamic} タグで囲みます。

テンプレートをインクルードする場合、 "データ" を使用する

SmartyおよびDwooの両者とも {include} を使用して、他のテンプレートのインクルードをサポートします。同時に {include something='something'} を使用して、両者ともテンプレート間でのデータ受け渡しをサポートします。しかし、あなたがDwooにおいて、"data" という名称の変数を渡した場合、ネーミングの衝突により、既存のデータは上書きされてしまいます。そのため、代わりに {include file='something.tpl' innerdata=$foo} を使用すべきです。

Section

Mahara 1.1において、私たちはループの代わりに {section} を使用しています。これは全くDwooとは互換性がないため、代わりにループにスイッチする方が理に適ってます