关于引入smarttemplate模板程序配置文件(common.inc.php)部份如下:
复制内容到剪贴板
代码:
// init smartytemplate
require_once SYS_ROOT.'/include/class.smarttemplate.php';
$page = new SmartTemplate;
$page->template_dir = SYS_ROOT.'./templates/';
$page->temp_dir = SYS_ROOT.'./templates_c/';
$page->cache_dir = SYS_ROOT.'./templates_c/';
$page->cache_lifetime = 0;我们在配置文件中就完成了初始化。
然后在实体的文件(index.php)中示例:
复制内容到剪贴板
代码:
require_once './include/common.inc.php';
$text = 'http://www.phpres.com';
$page->tpl_file = '/index.htm';
$page->assign( 'TITLE', $text );
$page->output();要解析的模板文析(index.htm)部份代码:
复制内容到剪贴板
代码:
<html>{TITLE} </html>最后显示结果如下:
跟大家推荐这个很不错的模板引擎,如果你跟我一样觉得smarty这家伙太大了,又想找一个又快又简单又稳定的替代方案,smarttemplate是你不错的选择。