语法有点类似velocity,比ejs要节省点键盘,呵呵。目前只运行于NodeJS上,浏览器版本待续~
如果你在寻找web框架里的模板引擎,除了ejs,jada神码的,还可以试试这个 liteview
###安装
npm install liteview
###github地址
https://github.com/fishbar/liteview
syntax:
* variable
#{var} #var
* if else
#{if(#var)} #{elseif(#var1)} #{else} #{end}
* foreach
#{foreach(#var)} #{end}
variable in foreach using #{[xxx]} , #[xxx]
magic var : #{[-]} , #{[_]} , #{[%]} // array index , array item , array length
* expression
#{(#a+1)}
#{(func(#a+1))}
api:
* init(base); init template base
* debug(bool); set debug
* reg(name,func); regist functions that called in the tpl
* preload(tpl); pre-compile the tpl file, and tpl will be cached ,so when call render, no more compile;
* render(tpl,data); return string (usually html code);