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函数中的属性比较像HTML语法中的属性。 静态值不需要引号引起来,但必须是纯字符串。 带或不带修饰器的变量都可以使用,而且也不需要引号, 甚至可以使用PHP函数的结果,插件结果和复杂的表达式。

一些属性要求布尔值(TRUEFALSE)。 它们可以直接写成truefalse。 如果属性没有被赋值,那么它会将true作为默认值。

Example 3.4. 函数属性语法


{include file="header.tpl"}

{include file="header.tpl" nocache}  // 等同于 nocache=true

{include file="header.tpl" attrib_name="attrib value"}

{include file=$includeFile}

{include file=#includeFile# title="My Title"}

{assign var=foo value={counter}}  // 插件结果

{assign var=foo value=substr($bar,2,5)}  // PHP函数结果

{assign var=foo value=$bar|strlen}  // 使用修饰器

{assign var=foo value=$buh+$bar|strlen}  // 复杂的表达式

{html_select_date display_days=true}

{mailto address="smarty@example.com"}

<select name="company_id">
  {html_options options=$companies selected=$company_id}
</select>

  

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 15 plus 18? (Are you human?)

Advertisement