Skip to content

rcbdev/Templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Templates

A simple JavaScript template library. Requires jQuery to be added to page.

Usage

To create a template, simply create a new script element on your page with an id of {0}-template, and fill it with HTML. Any value within {...} will be replaced with the corresponding property's value.

<script type="text/html" id="demo-template">
    <p>Hello {name}.</p>
</script>

The template can then be compiled by calling var myTemplate = $.templates("demo");. This returns a function that can then be called to produce a jQuery object containing the merged HTML.

var myTemplate = $.templates("demo");
myTemplate({name: "Joe Bloggs"});
// <p>Hello Joe Bloggs</p>

About

A simple JavaScript template library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors