Replace manual HTML generation by the use of Handlebars



snippets/9/client/old_v2.html
html  = '<ul>';
for (i = 0; i < data["items"].length; i++) {
    html += '<li>';
    html += data["items"][i]["text"];
    html += '<button class="delete" data-id="' +  data["items"][i]["_id"]["$oid"]  + '">x</a>';
    html += '</li>';
}
html += '</ul>';

snippets/9/client/v2.html
<script id="show-items-template" type="text/x-handlebars-template">
<ul>
{{#each data.items}}
    <li>{{ text }} <button class="delete" data-id="{{ _id.$oid }}">x</a></li>
{{/each}}
</ul>
</script>