3 ms·
If there is a particular data model that you want, there's no shame in just passing it directly inside the container of the view. Given a Handlebars template on
by cmwelsh 14y ago
If there is a particular data model that you want, there's no shame in just passing it directly inside the container of the view. Given a Handlebars template on the server like:
<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.