Ответ 1
Я бы рекомендовал использовать Underscore.js функциональность шаблонов. Вот пример того, как его использовать:
JS
// Using Underscore.js to create a function called 'template'
var template = _.template($('#messages-template').text());
// Passing in an object as an argument to the 'template' function
var compiled = template({ messages: <array of messages from Parse> });
// Appending into the body the HTML that was created from merging the object into the template
$(body).append(compiled);
HTML
<script type="text/template" id="messages-template">
<table>
<tbody>
<% messages.forEach(function(message) { %>
<tr>
<td><%= message %></td>
</tr>
<% }); %>
</tbody>
</table>
</script>
Обязательно ознакомьтесь с документами, чтобы лучше понять, как использовать его для его самых полных возможностей - http://underscorejs.org/#template.