Samples | 标签使用

 

Beetl标签类似JSP 的标签用法,内置了俩个web开发中最常用的标签,Layout标签和IncludeFileTemplate标签。

1 layout标签,如下是一个layout标签,允许标签的内容放置到layout标签指定的布局页面

content.html

layout标签指定一个layout布局页面,即layout.html,如下所示

layout.html

在运行content.html的时候,beetl会将标签体的正文的输出作为layoutContent变量的值,插入到layout.html页面里

Beetl代码如下

运行后的输出如下:

 

2 includeFileTemplate标签

Beetl 还内置了inlucdeFileTemplate标签,如:

<%includeFileTemplate("/header.html"){%>

静态内容

<%}%>

此标签将运行第一个参数指定的文件,作为模板输出,并忽略标签体的内容。你也可以直接

<% includeFileTemplate("/header.html"){} %>

查看用户指南了解更多Beetl标签信息,可以自定义标签,如cache标签