Socket
Socket
Sign inDemoInstall

@zollty/zollty-tmpl

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @zollty/zollty-tmpl

HTML Template Engine with JavaScript (JS-Template)


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

zollty-tmpl.js

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

Keywords

FAQs

Last updated on 22 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc