Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

frontend-tpl

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frontend-tpl

This is a simple fontend template engine

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Fontend-tpl

This is a simple fontend template engine

Language

English || 中文

Usage

Browser

<script src="dist/tpl.js"></script>
<!--
    If it work in prodution, you may use the following instead:
    <script src="dist/tpl.bundle.js"></script>
-->
<script>
    var tpl = new Tpl()
    var data = {
        divClass: 'div',
        out: 'outer'
    }
    var htmlString = ' \
        <div class="{{ divClass }}"> \
            <p>{{ "inner" }}</p> \
        </div> \
        <p>{{ out + "p" }}</p> \
    '
    var dom = tpl.parse(htmlString).render({ data: data }).getDom()
    /**
     * dom is:
     * [
     *  <div class="div">
     *      <p>inner</p>
     *  </div>,
     *  <p>outerp</p>
     * ]
    */
</script>

CommonJS

var Tpl = require('frontend-tpl')
var tpl = new Tpl()
// some code as above

Attention
If you want to use it in node environment, you should offer a environment of DOM.
For example, you can use the jsdom module.

Tests

You can download this depository and run npm test to see the unit test.

Docs

If you want to get more information, please see API Document

Keywords

ast

FAQs

Package last updated on 10 Jun 2019

Did you know?

Socket

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