nejt
v0.1.0
Published
a nice easy javascript template
Downloads
1
Readme
nejt
a nice easy javascript template, a embedded javascript template.
Installtion
Npm: npm install nejt
Bower: bower install nejt
Getting Started
Interpolation
var template = NEJT.compile('Hello, <%= name %>.<%= age %>');
template({name: 'Jack'}) // 'Hello, Jack.'
Using javascript in template
var str = '<%for(var i=0,user,len=users.length;i<len;i++){ %>\
<%= users[i].name %>\
<% if(i<len-1){ %>, <% } %>\
<% } %>';
var template = NEJT.compile(str);
var users = [{
name: "wwq",
age: 30
}, {
name: "hxl",
age: 32
}, {
name: "gp",
age: 33
}];
template({users: users}); // 'wwq, hxl, gp'
Custom delimiters
var str = '[[for(var i=0,user,len=users.length;i<len;i++){ ]]\
[[= users[i].name ]]\
[[ if(i<len-1){ ]], [[ } ]]\
[[ } ]]';
NEJT.config.startTag = '[[';
NEJT.config.endTag = ']]';
var template = NEJT.compile(str);
var users = [{
name: "wwq",
age: 30
}, {
name: "hxl",
age: 32
}, {
name: "gp",
age: 33
}];
template({users: users}); // 'wwq, hxl, gp'
LICENSE
MIT