xtemplate.js富逻辑的模板引擎
xtemplate 是独立的富逻辑模板引擎,基于浏览器和 Node.js 的可扩展的模板引擎库。
xtemplate 支持异步控制和继承,包括逻辑表达式,自定义函数等等。
xtemplate 语法类似 mustache
示例:
<!-- index.xtpl -->
{{extend ("./layout1")}}
{{#block ("head")}}
<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet" />
{{/block}}
{{#block ("body")}}
<!--index body block-->
<h2>{{title}}</h2>
{{/block}}
<!-- layout1.xtpl -->
<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>{{title}}</title>
{{{block ("head")}}}
</head>
<body>
{{{include ("./header")}}}
{{{block ("body")}}}
{{{include ("./footer")}}}
</body>
</html>
具体用法参考:https://github.com/yiminghe/xtemplate-on-browser
评论
