Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/funkymed/templatejs

templatejs
https://github.com/funkymed/templatejs

Last synced: about 2 months ago
JSON representation

templatejs

Awesome Lists containing this project

README

        

#TemplateJS
==========
Simple, easy, and ultra lightweight template-engine

##Author

Cyril Pereira

##Demo
http://med.planet-d.net/demo/web/templatejs

##Documentation

First add to your html page a template like this, don't forget to add the tpl class, it's used by the engine to pre-process templates.

~~~

<div class="box">
<strong>Nickname</strong> : {nickname}<br />
<strong>Age</strong> : {age}<br />
</div>

~~~

Start the engine.
~~~
template.initialize();
~~~
Get the template.
~~~
var _tpl = template.getTemplate('tplTest');
~~~
With a JSON object it's easy to inject content
~~~
var obj = [
{nickname:'discoboyz',age:22},
{nickname:'mariloo',age:25},
{nickname:'funkybrother',age:35}
];
$(obj).each(function()
{
var _h = template.format(_tpl,this);
$('#content').append(_h);
});
~~~