Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

ダブルクォート内に埋め込まれた変数

  • Smarty が "ダブルクォート" で囲まれた内容の中から 割り当てられた 変数 として認識するのは、変数名が数字・文字・_(アンダースコア)・[](ブラケット) のみで構成されているもののみです。詳細は 名前の付けかた を参照ください。

  • その他の文字、たとえば .(ピリオド)や $object>reference(オブジェクト参照)を含む場合は、 その変数を `バッククォート` で囲む必要があります。

  • 修飾子 を埋め込むことはできず、 常にクォートの外で適用する必要があります。

Example 3.5. 構文の例


{func var="test $foo test"}       <-- $foo を参照します
{func var="test $foo_bar test"}   <-- $foo_bar を参照します
{func var="test $foo[0] test"}    <-- $foo[0] を参照します
{func var="test $foo[bar] test"}  <-- $foo[bar] を参照します
{func var="test $foo.bar test"}   <-- $foo (not $foo.bar) を参照します
{func var="test `$foo.bar` test"} <-- $foo.bar を参照します
{func var="test `$foo.bar` test"|escape} <-- 修飾子はクォートの外で!

  

Example 3.6. 実用例


{* $tpl_name を値で置き換えます *}
{include file="subdir/$tpl_name.tpl"}

{* $tpl_name を置き換えません *}
{include file='subdir/$tpl_name.tpl'} <--

{* . を含むのでバッククォートで囲む必要があります *}
{cycle values="one,two,`$smarty.config.myval`"}

{* php スクリプトでの $module['contact'].'.tpl' と同じです
{include file="`$module.contact`.tpl"}

{* php スクリプトでの $module[$view].'.tpl' と同じです
{include file="`$module.$view`.tpl"}

  

escape も参照してください。

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors