browserify-templatejs
v3.1.4
Published
template.js的browserify编译插件
Readme
browserify-templatejs
template.js的browserify编译插件。
安装
$ npm install --save @templatejs/runtime # 安装template运行时
$ npm install --save-dev browserify-templatejs # 安装template编译插件配置
配置参数同template.js参数一样,其中expression参数会作为获取template的表达式。
通过命令行加载browserify-templatejs插件
browserify -t browserify-templatejs index.js > bundle.js可以通过template.config.json文件自定义配置
{
"sTag": "<#",
"eTag": "#>",
"sandbox": false // 沙箱模式
}新建模版文件demo.tmpl(后缀名必须为tmpl)
<div><#=abc#></div>在js中import模版文件,并渲染
// index.js
import tpl from './demo.tmpl';
document.getElementById('test').innerHTML = tpl({ abc: 'yanhaijing' });