Created
January 26, 2011 04:09
-
-
Save searls/796211 to your computer and use it in GitHub Desktop.
fun with underscore templates!
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
<script id="someTemplate" type="text/html"> | |
<span class="warning-image"></span><p>{{ error }}</p></span> | |
</script> | |
------ | |
(function($){ | |
$.fn.renderTemplate = function(name,context) { | |
$(this).html(_($('#'+name).html()).template(context)); | |
return this; | |
}; | |
})(jQuery); | |
-------- | |
$('#container').renderTemplate('someTemplate',{error: 'party time!'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment