- 发布日期:2014-03-28
- 点击数:1864
- 回到首页
一、mvc需要模板
模板",逻辑和表示依靠它联系。它是结合了html和脚本语言特征的一种表达方式。通过这种方式,表示层可以按照用户所希望的格式来显示经过逻辑层处理过的数据。如果你有windows平台下mfc的开发经验,那么一定会很熟悉document/documenttemplate/view的封装,这就是一个很典型的mvc例子。对于web应用来说,个人认为j2ee中的ejb/servlets/jsp是最强大的,当然还有简洁优美的structs。另一个很有名的实现就是com/dcom+asp,这个组合在我国是最多人使用的。
<html>
<head>
<title>$greetings</title>
</head>
<body>
$greetings
<body>
</html>
二、为什么选smarty?
三、可能遇到的问题
$smart->template_dir="smarty/templates/"
$smart->compile_dir="smarty/templates_c/"
$smart->config_dir="smarty/configs/"
$smart->cache_dir="smarty/cache/"
$smart->left_delimiter="{/"
$smart->right_delimiter="/}"
四、反衬和类比
$tpl->set_file('phplib','bigfile.htm')
$tpl->set_block('phplib','row','rows')
for($j=0$j<10$j++){
$tpl->set_var('tag',"$j")
$tpl->parse('rows','row',true)
}
$tpl->parse('out','phplib')
$tpl->p('out')
$smart->assign('row',$row)
$smart->display('bigfile.htm')
五、结论