ECJiaWiki:Smarty:基本语法-属性
跳到导航
跳到搜索
ECJia到家Smarty模版手册导航 |
---|
为什么选择Smarty? |
基本语法-变量 |
基本语法-函数 |
基本语法-属性 |
基本语法-双引号中嵌入变量 |
基本语法-数学计算 |
从PHP赋值的变量 |
Smarty保留变量 |
变量修饰器 |
内置函数 |
自定义函数 |
基本语法-属性
- 大多数函数 都会使用属性来定义或者修改它们的行为。 Smarty函数中的属性比较像HTML语法中的属性。 静态值不需要引号引起来,但必须是纯字符串。 带或不带修饰器的变量都可以使用,而且也不需要引号, 甚至可以使用PHP函数的结果,插件结果和复杂的表达式。
- 一些属性要求布尔值(TRUE 或 FALSE)。 它们可以直接写成true和false。 如果属性没有被赋值,那么它会将true作为默认值。
函数属性语法
{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>