handlebars.binding
This is a Handlebars plugin which allows using one-way data binding inside templates with a clean markup. It saves development time by offering a simple and powerful way of building highly interactive templates without re-rendering or updating the DOM manually.
Install
$ npm install --save handlebars.binding
Usage
var Handlebars = ;; var main = document;var context = foo: 123;var template = Handlebarstemplates"path/to/template";var nodes = Handlebars; nodes; contextfoo = 321; Handlebars;
Examples
bind
helper
Binding with {{bind "foo"}} Hello {{foo}}, {{bar}} Hello {{foo}}, {{bar}} {{#bind "foo"}} Hello {{foo}}, {{bar}}{{/bind}}
if
and unless
helper
Binding with {{if "foo" bind=true then="Hello" else="World"}} Hello {{foo}}, {{bar}} Hello {{foo}}, {{bar}} {{#if "foo" bind=true}} Hello {{foo}}, {{bar}}{{else}} Goodbye{{/if}}
each
helper
Binding with {{#each objects var="object" bind=true}} Item {{index}}: {{object.name}} {{object.content}}{{/each}} {{#each objects bind=true}} Item {{index}}: {{name}} {{content}}{{/each}} {{#each primitives var="primitive" bind=true}} Item {{index}}: {{primitive}}{{/each}} {{#each primitives bind=true}} Item {{index}}: {{$this}}{{/each}}
Unbinding and rebinding DOM
Handlebars;Handlebars;
License
MIT © Mateus Maso