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; ...

Get Instant Handlebars.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.