Skip to content

4simple/xtpl-deprecated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xtpl

a template engine based on kissy xtemplate(easier in express).

app.set("view engine", "xtpl");

and you can specify template file encoding(requires iconv-lite):

app.set("view encoding", "gbk");

layout

{{extend ("./layout")}}

Example

├── footer.xtpl
├── header.xtpl
├── index.xtpl
├── layout.xtpl
├── layout1.xtpl
└── sub
    └── header.xtpl

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>

render

res.render("index", {title: "xtpl engine!"})

output

<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>xtpl engine!</title>

<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet"  />

</head>
<body>
<h1>header</h1>
<h2>sub header</h2>

<!--index body block-->
<h2>xtpl engine!</h2>

<h1>footer</h1>

</body>
</html>

changelog

0.9.0

  • 优化性能
  • 删除 clearCache 接口

0.8.0