Last active
November 16, 2015 04:38
-
-
Save greggnakamura/776305837443493cdb87 to your computer and use it in GitHub Desktop.
Javascript: Handlebars JS basic template example
This file contains hidden or 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
//Grab the inline template | |
var template = document.getElementById('template').innerHTML; | |
//Compile the template | |
var compiled_template = Handlebars.compile(template); | |
//Render the data into the template | |
var rendered = compiled_template({name: "Luke", power: "force"}); | |
//Overwrite the contents of #target with the renderer HTML | |
document.getElementById('target').innerHTML = rendered; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment