富邏輯的模板引擎: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>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!