tmpl
a tiny&simple template engine with ES6 DNA
installation
via NPM:
Please use
tmpl
by io.js(v2.1.0)
npm isntall node-ts-tmpl --save
Basic Usage
assume that you have an object with the structure like:
username: 'DavidCai' isLogin: true lists: 1 2 3
variables
hello,{%=username%}<!--out put:-->hello,DavidCai
unescaped text
tmpl
will escape all text you put in {%=...%}, unless you put them in {%!...%}
{%!unescaped%}<!--out put:-->unescaped
if statement
{% if login %}has login!{% endif %}<!--out put:-->has login!
for loop
{% for value in lists%}{%value%}{% endfor %}<!--out put:-->123
API
render(tmpl_html, obj) String
options:
tmpl_html
: html file with thetmpl
statementobj
: object to fill thetmpl
statement