any-template-compiler

任意模板文件按照使用文档的语法编译输出内容

Usage no npm install needed!

<script type="module">
  import anyTemplateCompiler from 'https://cdn.skypack.dev/any-template-compiler';
</script>

README

any-template-compiler

编译器 使用方法 输入:一个模板文件,有特定的语法 输出:编译后的内容

语法

// <%% %%> 用于转义 // <% 脚本 // <%= 输出脚本值 // <%- 输出脚本值,unescape

使用

import renderTemplate from 'any-template-compiler'

let ret = renderTemplate('<html><body>title<%= title%><div><%- html%></div></body></html>',{title:'hello',html:'<div></div>'})

console.log(ret)