O'Reilly logo

Instant Handlebars.js by Gabriel Manricks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Top 6 features you need to know about

We just took a look at using both standard expressions and block helpers in your templates, but I think we are getting a little ahead of ourselves. Let's take a step back and talk about simple expressions.

Expressions

You already know that to output a simple JavaScript value, you simply wrap the properties key in two pairs of curly braces; but what you may not know is that forepart from just outputting the value, Handlebars is also HTML-encoding it. Take a look at the following code example:

<!DOCTYPE HTML> <html> <head> <title>Handlebars Expressions</title> <script src="handlebars.js"></script> </head> <body> <script id="template" type="template/handlebars"> {{content}} </script> <script> var src = document.getElementById("template").innerHTML; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required