LivelyKernel/LivelyKernel — pull request #62 by rksm (2012-11-01 22:52:00+00:00)
Title: Handlebars integration

[Handlebars](http://handlebarsjs.com/) is a simple templating mechanism based on CTemplates / Mustache.

This branch integrates it into Lively.

Handlebars templates can be used to integrate arbitrary HTML structures
into Lively and tie the Lively and HTML world together.

@bgnk @levjj @athomschke please review, thanks!

```js
// create a Handlebars morph and assign a simple HTML tree to it
m = new lively.morphic.HandlebarsMorph({}, "handlebarsTest");
m.openInWorld();
apps.Handlebars.set("handlebarsTest", '

test

');

// setting a model that is used when rendering
// note that when updating the model or the template changes will be
// rendered immediately
m.model = {heading: 'this is a test', list: ['Foo', 'Bar', 'Baz']}
apps.Handlebars.set("handlebarsTest",
'

{{heading}}

'
+ '

'
+ ' {{#each list}}
{{this}}
{{/each}}'
+ '

');

// bind events to a new method
apps.Handlebars.set("handlebarsTest",
'

A list

'
+ '

'
+ ' {{#each list}}'
+ '
{{this}}
'
+ ' {{/each}}'
+ '

');
m.addScript(function sayHello(evt,el) {
alert(el.textContent);
});
```