node-ts-tmpl

1.0.2 • Public • Published

tmpl

a tiny&simple template engine with ES6 DNA

Build Status Coverage Status

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 the tmpl statement
  • obj: object to fill the tmpl statement

/node-ts-tmpl/

    Package Sidebar

    Install

    npm i node-ts-tmpl

    Weekly Downloads

    0

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • qqqppp9998