Skip to content

Instantly share code, notes, and snippets.

@beshur
Created March 25, 2015 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beshur/19f8070f72fe8db2dbce to your computer and use it in GitHub Desktop.
Save beshur/19f8070f72fe8db2dbce to your computer and use it in GitHub Desktop.
getTpl - underscore templates shorthand
function getTpl(tpl, options) {
if (!tpl) return;
if (!options) options = null;
var prepare = false;
if (options == 1) {
options = {};
prepare = true;
console.log('prepare');
}
var viewHelpers = {}
_.extend(options, viewHelpers);
if (prepare) {
return _.template($(tpl).html());
} else {
return _.template($(tpl).html())(options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment