template4js#
The JavaScript template engine, support for running NodeJS and browser environment.
installation##
npm install template4js
usage##
<% for (var i = 0, l = list.length; i < l; i ++) { %> <%=list[i].index%>user: <%=list[i].user%> | site:<%=list[i].site%><% } %>
var template = http = ; var data = list : index : 1 user : 'baidu' site : '<a href="http://www.baidu.com" target="_blank">http://www.baidu.com</a>' index : 2 user : 'qq' site : 'http://www.qq.com' index : 3 user : 'ali' site : "http://www.taobao.com" ; var server = http;
- <%=var%> : output variable
- <%-var%> : output escaping after the variables
- <% include('./static/template/header.tpl') %> : Nested template
In the template, the variable, please are reflected in the data parameters. Please read demo.html or node_demo.js.
License##
Released under the MIT license