Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 

zollty-tmpl.js

npm npm

HTML Template Engine with JavaScript. (JS-Template)

Support most modern browsers, and NodeJS.

Latest stable version:v1.3.2

Characteristic

  1. fast, small and has no dependencies.
  2. support include inner template.
  3. support json, array and any js object as render data.
  4. concise syntax, easy to use.
  5. support all frequently-used browsers.
  6. support using html script or just string as template.
  7. support using under both browsers and nodejs.

Usage

Writing templates

uses script-tag to wrap template in html:

<script id="test" type="text/html">
<h1>{{title}}</h1>
<ul>
    {{each list as value i}}
        <li>Index. {{i + 1}} :{{value}}</li>
    {{/each}}
</ul>
</script>

or just write the template content in a file:

<h1>{{title}}</h1>
<ul>
    {{each list as value i}}
        <li>Index. {{i + 1}} :{{value}}</li>
    {{/each}}
</ul>

Render template

use zollty.render('test', data) to render template:

var data = {
	title: 'This is title',
	list: ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg']
};
var html = zollty.render('test', data);
document.getElementById('content').innerHTML = html;

See Examples

Download

NodeJS

Install

npm install zollty-tmpl

Usage

var template = require('zollty-tmpl');
var data = {list: ["aaa", "test"]};

var html = template(__dirname + '/index/main', data);

Change-log

Licenses

Released under the MIT, BSD, and GPL Licenses zollty.com

See: JS模板引擎原理

About

Fast String (and HTML) Template Engine with JavaScript 🐢🚀

Resources

Stars

Watchers

Forks

Packages

No packages published