beetl for循环渲染html字符串的方式,javascript
beetl if条件判断输出,html
beet自定义标签和标签引用,java
beetl html赋值,json
beetl渲染json,beetl注释、变量定义,jsp
更多文档请到:http://ibeetl.com/guide/#beetlide
beetl for循环输出
beetl for输出select option <select> @for(item in list){ <option value="${item.id}">${item}</option> @} </select> beetl for输出ul li html <ul> @for(item in list){ <li>${item}</li> @} </ul>
beetl定界符和占位符 函数
定界符号里是表达式,若是表达式跟定界符或者占位符有冲突,能够在用 “\” 符号,如ui
@for(user in users){ email is ${user.name}\@163.com @} ${[1,2,3]} //输出一个json列表 ${ {key:1,value:2 \} } //输出一个json map,} 须要加上\
beetl注释spa
Beetl语法相似js语法,因此注释上也同js同样: 单行注释采用// 多行注视采用/* */ <% /*此处是一个定义变量*/ var a = 3; //定义一个变量. /* 如下内容都将被注释 %> <% */ %>
beetl赋值htm
赋值于html中经常使用 ${ 服务端的变量 } 来作,这个于jsp是一致的。例如: <input value="${value}"> <div>${html}</div>
beetl if选择性输出变量格式化
支持三元表达式 ${a==1?"ok":''} ${a==1?"ok"} <input type="checkbox" ${a==0? "checked"}> <input ${a==0?"readonly"} /> <select> <option ${a==1?"selected"}>hello</option> <option>world</option> </select>
beetl标签函数
若是共用一个模版html 方法一: <% layout("/temlet/layout.html"){ %> //这里能够写上html <% } %> 方法二: @layout("/temlet/layout.html"){ //这里能够写上html @}
容许 include 另一个模板文件
<% include("/inc/header.html"){} %>
自定义HTML标签
<#button name="提交" handle="add()"/> file: /* button.tag */ <button onclick="${handle}">${name}</button>