标签
每个 Smarty 标签都会打印一个 变量 或调用某个函数。通过将函数及其 属性 用定界符括起来进行处理和显示,如下所示:{funcname attr1="val1" attr2="val2"}
.
示例
{config_load file="colors.conf"}
{include file="header.tpl"}
{if $logged_in}
Welcome, <span style="color:{#fontColor#}">{$name}!</span>
{else}
hi, {$name}
{/if}
{include file="footer.tpl"}
-
在模板中,内置函数和 自定义函数 的语法相同。
-
内置函数是 Smarty 的 **内部** 组件,例如
{if}
、{section}
和{strip}
。它们不需要更改或修改。 -
自定义标签是通过 插件 实现的 **附加** 标签。它们可以根据需要修改,您也可以创建新的。
{html_options}
就是一个自定义函数的示例。
另请参阅 registerPlugin()