php模板引擎smarty的基本语法

字体大小: 中小 标准 ->行高大小: 标准
注释
模板注释被*号包围,格式为: {* this is a comment *} 
例子:
 
{* include the header file here *}
{include file="header.tpl"}
{* display dropdown lists *}
<SELECT name=company>
{html_options values=$vals selected=$selected output=$output}
</SELECT>
 

函数
在smarty模板里无论是内建函数还是自定义函数都有相同的语法.
内建函数将在smarty内部工作,例如 {if}, {section} 和{strip}.他们不能被修改.
自定义函数通过插件机制起作用,它们是附加函数. 只要你喜欢,可以随意修改.你也可以自行添加.
例如 {html_options} and {html_select_date} 
函数语法:{funcname attr1="val" attr2="val"}
大多数函数都带有自己的参数以便于规定和修改他们的行为. 
smarty模板引擎里的函数的参数静态数值不需要加引号,但是字符串需要加。 
赋值时引用到变量也不需要加引号。
代码片段:
{html_select_date display_days=yes}
<SELECT name=company>
{html_options values=$vals selected=$selected output=$output}
</SELECT>
由上可知:参数为布尔值也不需要加双引号。

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/540.html