Skip to content
Fast String (and HTML) Template Engine with JavaScript 🐢🚀
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
docs
examples
src
.gitattributes
.gitignore
.npmignore
README.md
package.json

README.md

zollty-tmpl.js

HTML or String Template Engine with JavaScript

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: 引擎原理

You can’t perform that action at this time.