Smarty - the compiling PHP template engine | ||
---|---|---|
Prev | Chapter 16. Extending Smarty With Plugins 利用插件扩展smarty |
Next |
Compiler functions are called only during compilation of the template.
They are useful for injecting PHP code or time-sensitive static
content into the template. If there is both a compiler function and a
custom function registered under the same name, the compiler function
has precedence.
编译函数仅在模板编译过程中被调用。对于将PHP代码或对时间敏感的静态内容嵌入到模板中,他们是比较有用的。如果编译函数和普通函数都注册了同一个名字,则编译函数具有优先使用权。
The compiler function is passed two parameters: the tag argument
string - basically, everything from the function name until the ending
delimiter, and the Smarty object. It's supposed to return the PHP code
to be injected into the compiled template.
此编译函数有两个参数:标记参数字符串——基本上是从函数名字直到结束位置的所有内容,另一个参数是Smarty对象。该函数将返回嵌入到被编译模板中的PHP代码。
See also register_compiler_function(), unregister_compiler_function().