ts-template
嘿嘿嘿,一个基于模板字符串的模板引擎的最简实现~, 只适用于node环境,
usage 使用
模板字符串的语法,发挥想象吧,嘿嘿嘿~
test.js
const RenderClass = ; const renderVm = rootName: 'root' // 数据跟字段 defaut: 'root' baseDir: '' // 模板根目录 defaut: path.join(process.cwd(), 'view'); cache: true // 是否缓存 defaut: true renderVmrenderVm
test.html
ts-template include模板: ${await this.include('aa.html')} 嘿嘿嘿 1341 转意: ${e(root.b)} 自运行函数: ${(() => { return 'adadfadfasdf' })()}
extension 扩展
const RenderClass = ; { superopt } // format函数 { // ... } // async 函数 async { return { fs; }; } const renderVm = rootName: 'root' // 数据跟字段 defaut: 'root' baseDir: '' // 模板根目录 defaut: path.join(process.cwd(), 'view'); cache: true // 是否缓存 defaut: true renderVm// 或者renderVm