Created
September 6, 2012 13:40
-
-
Save empr/3656364 to your computer and use it in GitHub Desktop.
wrapper for underscore template.
This file contains hidden or 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
| var Template = (function() { | |
| var _cache = {}; | |
| function render(id, params) { | |
| if (_cache[id]) { | |
| return _cache[id](params); | |
| } | |
| $('script[type="text/template"]').each(function(i, e) { | |
| if (id === e.id) { | |
| _cache[id] = _.template($(e).text()); | |
| } | |
| }); | |
| return _cache[id](params); | |
| } | |
| return {render: render}; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment