Last active
December 18, 2015 04:19
-
-
Save nmoliveira/5724938 to your computer and use it in GitHub Desktop.
A very simple example using 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
<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