Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic (jquery) ajax template loading for underscore js
<h1>Foo is <%= foo %></h1>
<% _.each(baz,function(value,index){ %>
<h2>Baz <%= index %> is <%= value %>
<% }) %>
<script src=""></script>
<script src=""></script>
<script src="main.js"></script>
<div id="container"></div>
// underscore template loader
function _tpl(templateName,callback) {
var tmpl_url = '_tlp-' + templateName + '.html';
url: tmpl_url,
method: 'GET',
async: false,
contentType: 'text',
success: function (data) {
var template_data = {
var tpl = _.template(template);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.