gettpl

1.1.0 • Public • Published

getTpl

Small script that provides a very simple HTML template for your javascript projects.

Installation

On top of your javascript file :

import getTpl from 'gettpl';

Usage

  • The HTML template is in your HTML page (hidden) and contains variables to be replaced :
<script id="my_template_id" type="text/template">
    <span>
        {{ foo }}
    </span>
    <p>
        {{ foo2 }}
    </p>
</script>
  • In your javascript, call the template with its id and variables will be replaced via an object
getTpl({ 
    foo:'bar', 
    foo2:'bar2' 
}, 'my_template_id'); 

Returns:

<span>
    bar
</span>
<p>
    bar2
</p>

Readme

Keywords

Package Sidebar

Install

npm i gettpl

Weekly Downloads

1

Version

1.1.0

License

ISC

Last publish

Collaborators

  • romuleald