Skip to content

Instantly share code, notes, and snippets.

@nmoliveira
Last active December 18, 2015 04:19
Show Gist options
  • Save nmoliveira/5724938 to your computer and use it in GitHub Desktop.
Save nmoliveira/5724938 to your computer and use it in GitHub Desktop.
A very simple example using Handlebars.js
<html>
<head>
<title>Simple Handlebars Example</title>
</head>
<body>
<!-- Template -->
<script id="name-tmpl" type="text/x-handlebars-template">
<p>Title: {{ name }} </p>
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="handlebars.js"></script>
<script type="text/javascript">
$(function() {
var source = $('#name-tmpl').html();
var compiled = Handlebars.compile(source);
var rendered = compiled({name: 'Nuno'});
$('body').html(rendered);
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment