1.0.10 • Published 8 years ago

template-js v1.0.10

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

template-js

Simple and Easy Javascript Templates for Node.js.

Installation

npm install template-js

Usage

// Your code

var Template = require('template-js')

var my_template = new Template('my.tmpl', {text: "<h1>Hello World</h1>"})

console(my_template.toString())
// my.tmpl

This is a template.

It can render context items: {{ text }}

It can execute javascript:
{% for (i=0;i<3;i++) { %}
Number {{ i }}: {{ text }}
{% } %}

It can escape strings:
{- text -}

It can include subtemplates:

{{ include('sub.tmpl') }}

Enjoy!

Output:

This is a template.

It can render context items: <h1>Hello World</h1>

It can execute javascript:

Number 0: <h1>Hello World</h1>

Number 1: <h1>Hello World</h1>

Number 2: <h1>Hello World</h1>


It can escape strings:
&lt;h1&gt;Hello World&lt;/h1&gt;

It can include subtemplates:

Included templates are cool!

Enjoy!
1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago