Created
March 25, 2015 15:18
-
-
Save beshur/19f8070f72fe8db2dbce to your computer and use it in GitHub Desktop.
getTpl - underscore templates shorthand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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