jt

0.0.2 • Public • Published
Super easy template engine. Write templates in JSON!
var jt = require('jt');
 
var template = jt({
    tag: 'div',
    content: 'foo'
});
 
console.log(template()); // <div>foo</div>

Install

npm install jt

jt return function(template) that can be callen in future

API

You can create template from string, array, json and functions

var template = jt('hello');
 
template(); // 'hello'
var template = jt(['hello ', 'world']);
 
template(); // 'hello world'
var template = jt({
    tag: 'snap',
    class: 'text'
    content: ['hello ', 'world']
});
 
template(); // '<span class="text">hello world</span>'

Use function as argument to create dynamic templates

var template = jt(function (who) {
    return {
        tag: 'div',
        content: ['hello ', who]
    }
 
});
 
template('world'); // '<span class="text">hello world</span>'
var template = jt(function (who, action) {
    return {
        tag: 'div',
        content: [action, ' ', who]
    }
 
});
 
template('world', 'hello'); // '<span class="text">hello world</span>'

Readme

Keywords

none

Package Sidebar

Install

npm i jt

Weekly Downloads

1

Version

0.0.2

License

none

Last publish

Collaborators

  • metrofun