javascript template engine , node template engine , viewer(MVC)
OTHER License
npm install liteview # install version 0.1.1 +
var view = require('liteview').create();
view.init(tpl_base); // set template base to view
view.debug(true); //if needed, set debug ,view will console.log the debug info
view.render('test.html', {
name: 'liteview',
version: 'v x.x.x',
list:[
{name:'fish',address:'abc'},
{name:'cat',address:'def',child:[{item:'apple'},{item:'orange'}]},
{name:'dog',address:'ghi',array:['a','b','c']}
]
});
The test.html file:
<html>
<head></head>
<body>
#{set(totalPage = 5)}
#{if(#list)}
<ul>
#{foreach(#list)}
<li>
#{[-]} : #{[name]} - #{[address]}
#{foreach(#[child])}
<span>#{[item]}</span>
#{end}
#{foreach(#[array])}
<i>#{[_]}</i>
#{end}
#{for(var i=0;i<#var:totalPage;i++)}
<a href="/page/#{var:i}">page-#{var:i}</a>
#{end}
</li>
#{end}
</ul>
#{end}
</body>
</html>
Note: inline script must add ";" when needed!!!
Adapter to express connect