使用literal标签防止模板标签被解析php
例如html
{literal} {$name}<br/> {/literal}
{//注释内容}
{/*注释内容*/}
config.php里面模板设置相关加入以下内容app
'layout_on' => true, 'layout_name' => 'layout',
在view里面新增layout.html布局
<html> <head> <meta charset="utf-8"/> <title>模板布局</title> </head> <body> <div style="width:100%;height:100px; background-color:red;"> </div> {__CONTENT__} <div style="width: 100%; height:100px;background-color:blue;"> </div> </body> </html>
{__CONTENT__}里面包含index的内容
配置文件里面不用设置仅仅在index.html里面加入一个code
{layout name="模板名称"/}
略htm
在view下建立的模板base.html主要是{block}继承
<html> <head> <meta charset="utf-8"/> <title>模板继承</title> </head> <body> {block name="head"} <div style="width: 100%;height: 100px; background-color: yellow"> 这是基础模板的头部信息 </div> {/block}<br/> {block name="footer"} <div style="width: 100%;height: 100px;background-color: green"> 这是基础模板的底部信息 </div> {/block} </body> </html>
而后在index.html下utf-8
使用it
{extend name="base" /}
便可继承从而渲染,不事后面的内容会被覆盖,若是不想被覆盖在index.html里面不想被覆盖的block后面加一个io
{__block__}便可
注意区块以外的内容是不会被渲染的
{include file='模版文件1,模版文件2,...' }
例如在一个html里面包含一个html并进行渲染
{include file='../application/index/view/index/lang.html'}