Data binding to Mustache templates? (preferably clean and simple)

Viewed 7536

What I am after is a piece of code that could provide me a clean and simple one-way solution to bind the changes from DOM to the object that is used to render it.

Example: And object

{name: 'Joe'}

is used to render the Mustache template

<div><input val="{{name}}" /></div>

How can I match the change event in the inputfield to the correct property?

What about iterations?

{{#users}}
<div><input val="{{name}}" /></div>
{{/users}}

Is there a such thing?

Edit: And yes, I am aware of Backbone, Angular, Ember, younameit. However, what I need is a specific case to Mustache/Handlebars.

5 Answers

I suggest you look at vue.js - it's now a widely adopted framework and is much lighter than Angular (600kb vs 60kb minified and 20kb if gzipped) and uses mustache-similar syntax.

Related