liuz-wxapp-template

A simple template for wxapp, mimicing lodash.template api. It supports following syntax:

Usage no npm install needed!

<script type="module">
  import liuzWxappTemplate from 'https://cdn.skypack.dev/liuz-wxapp-template';
</script>

README

wxapp-template

A simple template for wxapp, mimicing lodash.template api. It supports following syntax:

  1. <%= variable %> print out raw variable
  2. <%- variable %> html escape variable
  3. <% if (variable) { %> XXX <% } %> evaluate condition based on variable

Install

$ npm install liuz-wxapp-template

Usage

const template = require('liuz-wxapp-template');
var tpl = 'Hello <%= username %>!';
var data = {
    username: 'Spiderman',
}

console.log(template(tpl)(data));