# handlebars.binding **Repository Path**: mirrors_silverwind/handlebars.binding ## Basic Information - **Project Name**: handlebars.binding - **Description**: Handlebars plugin for using one-way data binding - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-05-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README handlebars.binding [![Build Status](https://travis-ci.org/mateusmaso/handlebars.binding.svg?branch=master)](https://travis-ci.org/mateusmaso/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 ```javascript var Handlebars = require("handlebars"); require("handlebars.binding").default(Handlebars); var context = {foo: 123}; var template = Handlebars.templates["path/to/template"]; var nodes = Handlebars.parseHTML(template(context)); context.foo = 321; Handlebars.update(); ``` ## Examples ### Binding with ```bind``` helper ```html

{{bind "foo"}}

Hello {{foo}}, {{bar}}

Hello {{foo}}, {{bar}}

{{#bind "foo"}}

Hello {{foo}}, {{bar}}

{{/bind}} ``` ### Binding with ```if``` and ```unless``` helper ```html

{{if "foo" bind=true then="Hello" else="World"}}

Hello {{foo}}, {{bar}}

Hello {{foo}}, {{bar}}

{{#if "foo" bind=true}}

Hello {{foo}}, {{bar}}

{{else}}

Goodbye

{{/if}} ``` ### Binding with ```each``` helper ```html {{#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 ```javascript Handlebars.unbind(node); Handlebars.bind(node); ``` ## License MIT © [Mateus Maso](http://www.mateusmaso.com)