Skip to content

Instantly share code, notes, and snippets.

@EragonJ
Created November 4, 2013 09:49
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 EragonJ/7300364 to your computer and use it in GitHub Desktop.
Save EragonJ/7300364 to your computer and use it in GitHub Desktop.
Template 2 with Handlebars.js
<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>
$(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