Get Smarty

Donate

Donate Bitcoin Bitcoin
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

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

�引�中嵌入��

  • Smartyå�¯ä»¥è¯†åˆ«å‡ºåœ¨å�Œå¼•å�·ä¸­åµŒå¥—çš„ å�˜é‡�值,这些å�˜é‡�å��ç§°å¿…é¡»å�ªåŒ…括 å­—æ¯�ã€�数字和下划线。 å�‚è§�命å��规则。

  • å�¦å¤–,带有其他字符的,如点å�·ï¼ˆ.)或者 $object->referenceå½¢å¼�çš„å�˜é‡�, 必须用`å�•引å�·`括起æ�¥ã€‚

  • Smarty3中å…�许在å�Œå¼•å�·ä¸­åµŒå…¥Smarty的标签并è¿�行。 如果你需è¦�在å�Œå¼•å�·çš„å�˜é‡�上使用修饰器ã€�æ�’件或者PHP函数等,这是é�žå¸¸æœ‰ç”¨çš„。

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 (�是 $foo.bar)
{func var="test `$foo.bar` test"}        // 识别�� $foo.bar
{func var="test `$foo.bar` test"|escape} // 引�外的修饰器!
{func var="test {$foo|escape} test"}     // 引�内的修饰器!
{func var="test {time()} test"}          // PHP函数结果
{func var="test {counter} test"}         // �件的结果
{func var="variable foo is {if !$foo}not {/if} defined"} // Smarty区�函数

  

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`"}

{* 当��包�了点�“.�,必须用�引�括起� *}
{include file="`$module.contact`.tpl"}

{* 点���跟��� *}
{include file="`$module.$view`.tpl"}

  

Note

虽然Smarty能处�比较��的表达�和语法,但是最好��模�语法的简�, 把关注的焦点放在显示层�。如果你�现模�语法�常��,那么 最好把这些逻辑代�转移到�件或者修饰器上,用PHP代�进行编写。

��字符转�。

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 14 plus 12? (Are you human?)

Advertisement