Smarty comes with several built-in functions.
Built-in functions are integral to the template language.
You cannot create custom functions with the same names, nor can you modify
built-in functions.
Smarty自带很多内建函数.
内建函数是模板语言的一部分.
你不能自定义名称和内建函数一样的自定义函数,也不能擅自修改内建函数.
capture is used to collect the output of the template into a variable instead
of displaying it.
Any content between {capture name="foo"} and {/capture} is collected into
the variable specified in the name attribute.
The captured content can be used in the template from the special variable
$smarty.
capture.foo where foo is the value passed in the name attribute. If you
do not supply a name attribute, then "default" will be used.
All {capture} commands must be paired with {/capture}. You can nest capture
commands.
capture函数的作用是收集模板输出的数据到一个变量里,而不是把它们输出到页面.
任何在 {capture name="foo"}和{/capture}之间的数据都被收到了由函数的名称属性指定的变量里($foo).
收集的信息可以用在特殊变量$smarty里.
例如capture.foo就收集了以上数据.如果函数没有名字属性,将使用"default".
每个{capture}都必须对应{/capture},也不能嵌套使用capture函数
Technical Note:
Smarty 1.4.0 - 1.4.4 placed the captured content into the variable named $return.
As of 1.4.5, this behavior was changed to use the name attribute, so update your templates accordingly.技术提示:
Smarty 1.4.0 - 1.4.4把收集的内容放到了$return变量里.
在1.4.5以后就收集到了名字属性指定的变量里.请升级你的模板
Caution |
Be careful when capturing {insert} output. If you have caching turned on and you have {insert} commands that you expect to run within cached content, do not capture this content. |
警告 |
在抓取{insert} 的输出的时候请小心.如果你打开了缓存并指望 {insert} 指令运行在缓存的内容里,不要抓取这些内容. |