【文件属性】:
文件名称:tpl:将 html 模板转换为 javascript
文件大小:15KB
文件格式:ZIP
更新时间:2021-05-31 22:01:48
JavaScript
#将html模板转化为javascript模块
##目的
减轻前端拼接大量HTML以及维护时候的困难程度
##安装
安装node,参见:
安装npm,参见:
安装tpl
npm方式:
$ npm install tpl2js -g
源码方式:
$ cd ~
$ git clone git://github.com/caolvchong/tpl.git
$ cd tpl
$ vim ~/.bashrc
添加 alias tpl=~/tpl/lib/tpl.bin.js,保存
##html模板语法
###变量
HTML中的输出变量使用{{...}}
###语句:支持if语句,for语句,语句使用{{}}括起来
if语法:(else if 和 else 可选)
{{if(...)}}
...
{{else if(...)}}
...
{
【文件预览】:
tpl-master
----.gitignore(126B)
----package.json(625B)
----samples()
--------nodemodule()
--------default.css(630B)
--------function()
--------template.html(2KB)
--------seajs()
----README.md(3KB)
----lib()
--------index.js(658B)
--------tpl.bin.js(2KB)
--------tpl.core.js(6KB)