Skip to content


Subversion checkout URL

You can clone with
Download ZIP
jQuery.tpl: Javascript template engine
Latest commit b827afc @indutny Merge branch 'dev'
Failed to load latest commit information.
fonts New demo with webfonts and progressbars and centrify
test No specific changes
zip zip release
.gitignore no message
README.rdoc Removed unused {} and changed all other to []
benchmark.html Still merging...
benchmark.js Removed unused {} and changed all other to []
build_block.bat Still merging...
build_filter.bat Still merging...
build_main.bat Still merging...
index.html Still merging...
jquery.js 0.3.2
jquery.tpl.block.js Still merging...
jquery.tpl.block.min.js Still merging...
jquery.tpl.filter.min.js Filter.min.js
jquery.tpl.js JSDocs fixed
jquery.tpl.min.js removed creation of array from eval
test.html Still merging...
test.min.html test.min version


jQuery.tpl project: simple, fast and powerfull templates for jQuery and javascript (

It's easy to learn - start now!

Basic examples:

$.template(“1 + 1 = {%= 1+1 %}”) .html(); // 1 + 1 = 2 $.template(“Hello {%= a %}!”,[“a”]) .html({a: 'World'}); // >> Hello World! $.template(“Hello {%each a%}{%= this %}, {%/each%}world!”,[“a”]) .html({a: ['Andy','Alex']}); // >> Hello Andy, Alex, World! $.template(“{%if godmode%}My Lord!{%else%}Who are you?{%/if%}”,[“godmode”]) .html({godmode: true}); // >> My Lord!

Medium examples:

$.template(“{%catch var a %}What's up, dude?{%/catch%} {%= a.substr(0,9) %}?”) .html(); // >> What's up? $.template(“{%~ var a = true; %}{%if !a %}'a' is false?{%/if%}”,[“a”]) .html(); // >> 'a' is false? $.template(“{%@ name(value) { return '~' + value + '~' } %}{%= name('fancy')%}”) .html() // >>~fancy~

Harder examples:

$.template(“<div></div>”)(); // >> jQuery object of “div” $.template(“<div></div>”,[],“name”); // Store this template by “name” $.template(“name”)(); // >> jQuery object of “div” again $.template(“<button>{%= value%}</button>”,[“value”],“input”); $.template(“{%: input {value:'Hello world!'} %}”)(); // >> Button with text “Hello world!” $.template(“{%catch var temp%}<button>{%= value%}</button>{%/catch%}\ {%= $(temp).click(function(){alert(msg)}) %}”,[“value”,“msg”],“input”); $.template(“{%: input {value:'Hello world!', msg: 'Alarm!'} %}”)(); // >> Button with text “Hello world!” and alerting “Alarm!” on click

Block module

$.template(“<div>Hello, {%block 'username'%}{%/block%}!</div>”,[],“block”); $.template(“{%extends 'block'%}{%block 'username'%}Admin{%/block%}”)().html(); // >> Hello, Admin!

Something went wrong with that request. Please try again.