Installation

Npm

npm install art-template --save

Real-time compilation in browser

download:template-web.js(gzip: 6kb)

compatibility

IE8+(IE8 needs patch for execution. example

difference

Because browser doesn’t support file system, so template(filename, data) doesn’t support passing in file paths, and inside the method it uses document.getElementById(filename).innerHTML to obtain templates. For instance:

<script src="lib/template-web.js"></script>
<script id="tpl-user" type="text/html">
{{if user}}
<h2>{{user.name}}</h2>
{{/if}}
</script>

Pre-compilation in browser

use loader of webpack: art-template-loader.

Plugins