Co-Authored-By: Jean-Michel Claus <jmc@edx.org> Co-Authored-By: Brian Talbot <btalbot@edx.org> Co-Authored-By: Tim Babych <tim@edx.org> Co-Authored-By: Oleg Marshev <oleg@edx.org> Co-Authored-By: Chris Rodriguez <crodriguez@edx.org>
23 lines
675 B
JavaScript
23 lines
675 B
JavaScript
;(function (define, undefined) {
|
|
'use strict';
|
|
define(['jquery', 'underscore'], function($, _) {
|
|
/**
|
|
* Loads the named template from the page, or logs an error if it fails.
|
|
* @param name The name of the template.
|
|
* @return The loaded template.
|
|
*/
|
|
var loadTemplate = function(name) {
|
|
var templateSelector = '#' + name + '-tpl',
|
|
templateText = $(templateSelector).text();
|
|
if (!templateText) {
|
|
console.error('Failed to load ' + name + ' template');
|
|
}
|
|
return _.template(templateText);
|
|
};
|
|
|
|
return {
|
|
loadTemplate: loadTemplate
|
|
};
|
|
});
|
|
}).call(this, define || RequireJS.define);
|