Socket
Socket
Sign inDemoInstall

frontend-tpl

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    frontend-tpl

This is a simple fontend template engine


Version published
Maintainers
1
Created

Readme

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

FAQs

Last updated on 10 Jun 2019

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