Created
November 4, 2013 09:49
-
-
Save EragonJ/7300364 to your computer and use it in GitHub Desktop.
Template 2 with Handlebars.js
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
<script id="entry-template" type="text/x-handlebars-template"> | |
<div id="tmpl"> | |
<h1 class="header">{{header}}</h1> | |
<p class="content">{{content}}</p> | |
</div> | |
</script> | |
<body> | |
<div class="target"></div> | |
</body> |
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
$(document).ready(function() { | |
var tmplSource = $("#entry-template").html(); | |
// you can cache this tmpl for later use | |
var tmpl = Handlebars.compile(tmplSource); | |
$(".target").append(tmpl( | |
'header' : 'This is Header', | |
'content' : 'This is Content' | |
)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment