<div class="profile-widget" {{#if serverEnv}}data-model="{{jsonStringify profileModel}}"{{/if}}>
<span class="name">{{name}}</span>
<span class="phone">{{phone}}</span>
</div>
They can share the same template with some minor conditional statements. The JavaScript could simply load any model(s) required from the JSON in the data attribute and re-render the view in "enhanced mode".It comes in handy for progressive enhancement.
Airbnb is working on something similar as well using Node+Backbone but it's not available yet. They said they're planning on open sourcing it eventually but we'll have to wait a few months. http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-t...
You're talking about data -> template binding. I'm talking about the reverse, where some data (as a model) is recovered from a partial server-side render of the page, based upon the "patterns" described in the templates.
For example, if Angular did this (I don't think it does), it could traverse the generated HTML and compare it with the original template to figure out what's what.
I'm using Rails, and https://github.com/gazay/gon gem does it for you nicely.