Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funkymed/templatejs
templatejs
https://github.com/funkymed/templatejs
Last synced: about 2 months ago
JSON representation
templatejs
- Host: GitHub
- URL: https://github.com/funkymed/templatejs
- Owner: funkymed
- Created: 2013-03-28T05:24:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-07T15:33:05.000Z (over 7 years ago)
- Last Synced: 2024-04-13T16:21:42.879Z (9 months ago)
- Language: HTML
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);
});
~~~