Wiki

Clone wiki

JPT / Home

What's JPT ?

It's a browserside templates engine written in Javascript which uses Jascript as templating language. It supports script tags inside the templates, unobstrusive event hooking and generates documentFragments as result.

Live test

Example:

Template:

#!code

//xmp tag content isn't processed by any browser
<xmp id="jpt_template">
<i>Saying hi 5 times</i>
<ul>
<! for( var i = 0; i < 5; i++ ) { !>
    <li>Hi <!= i+1 !></li>
<! } !>
</ul>
</xmp>

Javascript code:

#!javascript

//It gets the template, process it, caches it as Javascript function and inserts it into the element 'my_div'.
JPT.insert( 'jpt_template', 'my_div' );

my_div's html

#!html
<i>Saying hi 5 times</i>
<ul>
    <li>Hi 1</li>
    <li>Hi 2</li>
    <li>Hi 3</li>
    <li>Hi 4</li>
    <li>Hi 5</li>
</ul>

Updated