Clean up duplicated code in setup.js

(imported from commit 86566f194497b618dff0be6ea2bc829204d03366)
This commit is contained in:
Keegan McAllister 2012-10-26 16:04:01 -04:00
parent 3e86da67f9
commit faa7565a75
1 changed files with 5 additions and 4 deletions

View File

@ -13,10 +13,11 @@ $(function () {
} }
// Compile Handlebars templates. // Compile Handlebars templates.
templates.message = Handlebars.compile($("#template_message").html()); $.each(['message', 'subscription', 'userinfo_popover_title', 'userinfo_popover_content'],
templates.subscription = Handlebars.compile($("#template_subscription").html()); function (index, name) {
templates.userinfo_popover_title = Handlebars.compile($("#template_userinfo_popover_title").html()); templates[name] = Handlebars.compile($('#template_'+name).html());
templates.userinfo_popover_content = Handlebars.compile($("#template_userinfo_popover_content").html()); }
);
// This requires that we used Django's {% csrf_token %} somewhere on the page. // This requires that we used Django's {% csrf_token %} somewhere on the page.
var csrftoken = $('input[name="csrfmiddlewaretoken"]').attr('value'); var csrftoken = $('input[name="csrfmiddlewaretoken"]').attr('value');