node-ts-tmpl
v1.0.2
Published
a tiny&simple template engine with ES6 DNA
Downloads
7
Readme
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
<p>hello,{%=username%}</p>
<!--out put:-->
<p>hello,DavidCai</p>
unescaped text
tmpl
will escape all text you put in {%=...%}, unless you put them in {%!...%}
{%!<p>unescaped</p>%}
<!--out put:-->
<p>unescaped</p>
if statement
{% if login %}
<p>has login!</p>
{% endif %}
<!--out put:-->
<p>has login!</p>
for loop
{% for value in lists%}
<span>{%value%}</span>
{% endfor %}
<!--out put:-->
<span>1</span>
<span>2</span>
<span>3</span>
API
render(tmpl_html, obj) String
options:
tmpl_html
: html file with thetmpl
statementobj
: object to fill thetmpl
statement