{"id":15091710,"url":"https://github.com/mateusmaso/handlebars.binding","last_synced_at":"2025-04-12T06:31:07.734Z","repository":{"id":12464992,"uuid":"15129643","full_name":"mateusmaso/handlebars.binding","owner":"mateusmaso","description":"Handlebars plugin for using one-way data binding ","archived":false,"fork":false,"pushed_at":"2018-02-04T20:55:52.000Z","size":266,"stargazers_count":29,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T12:35:51.875Z","etag":null,"topics":["data-binding","handlebars","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mateusmaso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-12T07:29:15.000Z","updated_at":"2022-08-30T14:00:45.000Z","dependencies_parsed_at":"2022-09-15T08:20:36.452Z","dependency_job_id":null,"html_url":"https://github.com/mateusmaso/handlebars.binding","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusmaso%2Fhandlebars.binding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusmaso%2Fhandlebars.binding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusmaso%2Fhandlebars.binding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusmaso%2Fhandlebars.binding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mateusmaso","download_url":"https://codeload.github.com/mateusmaso/handlebars.binding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429121,"owners_count":21101785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-binding","handlebars","javascript"],"created_at":"2024-09-25T10:43:00.327Z","updated_at":"2025-04-12T06:31:03.007Z","avatar_url":"https://github.com/mateusmaso.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"handlebars.binding [![Build Status](https://travis-ci.org/mateusmaso/handlebars.binding.svg?branch=master)](https://travis-ci.org/mateusmaso/handlebars.binding)\n==================\n\nThis 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.\n\n## Install\n\n```\n$ npm install --save handlebars.binding\n```\n\n## Usage\n\n```javascript\nvar Handlebars = require(\"handlebars\");\nrequire(\"handlebars.binding\").default(Handlebars);\n\nvar main = document.querySelector(\"main\");\nvar context = {foo: 123};\nvar template = Handlebars.templates[\"path/to/template\"];\nvar nodes = Handlebars.parseHTML(template(context));\n\nnodes.forEach((node) =\u003e main.appendChild(node));\n\ncontext.foo = 321;\n\nHandlebars.update();\n```\n\n## Examples\n\n### Binding with ```bind``` helper\n\n```html\n\u003ch1\u003e{{bind \"foo\"}}\u003c/h1\u003e\n\n\u003ch1 {{bind \"foo\" attr=true}}\u003e\n  Hello {{foo}}, {{bar}}\n\u003c/h1\u003e\n\n\u003ch1 {{bind \"foo\" attr=\"class\"}}\u003e\n  Hello {{foo}}, {{bar}}\n\u003c/h1\u003e\n\n{{#bind \"foo\"}}\n  \u003ch1\u003eHello {{foo}}, {{bar}}\u003c/h1\u003e\n{{/bind}}\n```\n\n### Binding with ```if``` and ```unless``` helper\n\n```html\n\u003ch1\u003e{{if \"foo\" bind=true then=\"Hello\" else=\"World\"}}\u003c/h1\u003e\n\n\u003ch1 {{if \"foo\" bindAttr=true then=\"disabled\" else=\"enabled\"}}\u003e\n  Hello {{foo}}, {{bar}}\n\u003c/h1\u003e\n\n\u003ch1 {{if \"foo\" bindAttr=\"class\" then=\"hello\" else=\"goodbye\"}}\u003e\n  Hello {{foo}}, {{bar}}\n\u003c/h1\u003e\n\n{{#if \"foo\" bind=true}}\n  \u003ch1\u003eHello {{foo}}, {{bar}}\u003c/h1\u003e\n{{else}}\n  \u003ch1\u003eGoodbye\u003c/h1\u003e\n{{/if}}\n```\n\n### Binding with ```each``` helper\n\n```html\n{{#each objects var=\"object\" bind=true}}\n  \u003ch2\u003eItem {{index}}: {{object.name}}\u003c/h2\u003e\n  \u003cp\u003e{{object.content}}\u003c/p\u003e\n{{/each}}\n\n{{#each objects bind=true}}\n  \u003ch2\u003eItem {{index}}: {{name}}\u003c/h2\u003e\n  \u003cp\u003e{{content}}\u003c/p\u003e\n{{/each}}\n\n{{#each primitives var=\"primitive\" bind=true}}\n  \u003ch2\u003eItem {{index}}: {{primitive}}\u003c/h2\u003e\n{{/each}}\n\n{{#each primitives bind=true}}\n  \u003ch2\u003eItem {{index}}: {{$this}}\u003c/h2\u003e\n{{/each}}\n```\n\n### Unbinding and rebinding DOM\n\n```javascript\nHandlebars.unbind(node);\nHandlebars.bind(node);\n```\n\n## License\n\nMIT © [Mateus Maso](http://www.mateusmaso.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusmaso%2Fhandlebars.binding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmateusmaso%2Fhandlebars.binding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusmaso%2Fhandlebars.binding/lists"}