Name
compileAllTemplates() — 编译全部模板
说明
string compileAllTemplates(string extension,
boolean force,
integer timelimit,
integer maxerror);
该函数将编译$template_dir目录下的模板文件。
参数如下:
extension字符串,指定模板文件的后缀名。默认为“.tpl”。force布尔值。设定是否仅编译已修改的模板文件(false)或强制编译全部模板文件(true)。默认是false。timelimit整型,设定模板编译过程的时间限制。默认是无限制。maxerror整型,设定编译过程中出现的最大错误次数,超过此次数将停止编译。默认是无限制。
Note
该函数有可能不会生成全部预期的编译结果,所以使用会有一定风险。
Note
如模板需要注册插件、过滤器或对象等,在执行该函数之前必须先注册这些东西。
Note
如果使用模板继承,那么该函数将编译产生父模板的编译文件,但这些编译文件将永远也不会被使用到。
Example 14.15. compileAllTemplates()
<?php
include('Smarty.class.php');
$smarty = new Smarty;
// 强制编译全部模板
$smarty->compileAllTemplates('.tpl',true);
?>