Skip to content

romuleald/getTpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published