3.1.4 • Published 6 months ago

browserify-templatejs v3.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

browserify-templatejs

npm.io

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' });

贡献者列表

contributors

:gear: 更新日志

CHANGELOG.md

:airplane: 计划列表

TODO.md