xtemplate.js富邏輯的模板引擎
xtemplate 是獨(dú)立的富邏輯模板引擎,基于瀏覽器和 Node.js 的可擴(kuò)展的模板引擎庫。
xtemplate 支持異步控制和繼承,包括邏輯表達(dá)式,自定義函數(shù)等等。
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
評(píng)論
圖片
表情
