What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
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
も参照してください。