Skip to content

Instantly share code, notes, and snippets.

@beriberikix
Created May 14, 2012 05:04
Show Gist options
  • Save beriberikix/2691867 to your computer and use it in GitHub Desktop.
Save beriberikix/2691867 to your computer and use it in GitHub Desktop.
Handlebars noob
<html>
<head>
<title>Trying Handlebar</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0.beta6/handlebars.min.js"></script>
</head>
<body>
<div class="output"></div>
<script id="template" type="text/x-handlebars-template">
<span>{{name}}</span>
</script>
<script type="text/javascript">
var source = document.querySelector('#template');
var template = Handlebars.compile(source);
var context = { name: "beriberikix" };
var htmlOutput = template(context);
console.log(htmlOutput);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment