jQuery.tpl: Javascript template engine
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
fonts
test
zip
.gitignore
README.rdoc
benchmark.html
benchmark.js
build_block.bat
build_filter.bat
build_main.bat
index.html
jquery.js
jquery.tpl.block.js
jquery.tpl.block.min.js
jquery.tpl.filter.js
jquery.tpl.filter.min.js
jquery.tpl.js
jquery.tpl.min.js
test.html
test.min.html

README.rdoc

jQuery.tpl project: simple, fast and powerfull templates for jQuery and javascript (github.com/donnerjack13589/jsTPL).

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!”,) .html({a: ['Andy','Alex']}); // >> Hello Andy, Alex, World! $.template(“{%if godmode%}My Lord!{%else%}Who are you?{%/if%}”,) .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%}”,) .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%}”,,“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!