Book Image

Instant Handlebars.js

By : Gabriel Manricks
Book Image

Instant Handlebars.js

By: Gabriel Manricks

Overview of this book

Handlebars is one of the leading JavaScript templating engines and is quickly gaining widespread adoption by developers, as well as with frameworks like Ember.js and Meteor. "Instant Handlebars.js" is a complete guide to the Handlebars library filled with internal concepts and practical examples that will help illustrate what's going on and take you from a complete beginner to a Handlebars expert. "Instant Handlebars.js" begins with the very basics, requiring no previous knowledge about templating engines. Throughout the course of this book, you get a thorough tour of all the features available in Handlebars.js and you will learn how to organize your websites for both development and production. In this book, we will cover how to create templates with both placeholders and helpers. We will then go into organizing your projects for rapid -development using Require.js and how to optimize and compile your projects for production. To finish off, you will learn how to annotate your code and leave debug points so that you can easily maintain and troubleshoot your code in the future. Handlebars is a small library;, it is meant to fill a specific need and it does this well. "Instant Handlebars.js" takes a very methodical approach to cover every aspect of this amazing library with practical examples provided every step of the way.
Table of Contents (7 chapters)

People and places you should get to know

Congratulations for making it this far. You are now an expert on both using and implementing Handlebars in your own apps. But having a set of skills or preferred libraries always requires you to subscribe to them: keeping up with changes they make, and even contributing ideas and code, advancing your environment even further. In this section we will be taking a look at both some of the people and also some of the places you should follow, so as to stay up to date and dive deeper into the Handlebars community.

The first place I would like to single out is the official Handlebars site at If you have any questions or are just looking to see whether there have been any changes, this is a good place to look first (not to mention you can support the project and buy some Handlebars gear).

Official sites

Handlebars is not a large library; it's made to solve one specific issue and it does it well. With that said, I think it is the kind of library where you can take some time and learn the source. You may need to whip out a pad of paper and some markers to draw out the event flows, and maybe even debug it in JavaScript, but it's more than worth it. The compiled final source can be found at, and while it does sometimes get a bit technical, there are some good coding concepts you can pick up, as well as learn some of Handlebars inner workings, which you can take advantage of at will.

To view the rest of the source, you can just view the entire repo here at This is also where you will want to post issues, as well as make pull-requests to add new features.

Also, if you would like to learn more about require.js and what it can do, be sure to take a look at its official homepage it contains a lot of good information.


Another resource that has become almost essential to any library is Stack Overflow. For pretty much any library around, you can ask both questions as well as contribute answers, or view solved problems. Just search for questions tagged Handlebars or even add your own at

Another great site where I personally published two articles is NetTuts+. You can find the articles here:

There is also a great series on Treehouse at the following links:


A templating engine is really only one piece of a web app, and while you can really implement Handlebars into any framework, there are some that use Handlebars by default and come preconfigured with it.

Ember.js is an amazing web framework built by the creator of Handlebars, Yehuda Katz, and as such it embeds Handlebars deep within its core, so there is no need to pre-compile templates or load different scripts, as a lot of it is taken care of for you. It implements smart code generation, so you really only code the minimum, and I highly recommend you visit, if you are serious about learning Ember.js.

Another framework, which comes pre-installed with Handlebars, is Meteor.js. Meteor is both a client and a frontend and backend framework that abstracts this connection to try and make your app update in real time, by persisting all changes to the backend and syncing any new updates to your browser at


Last, but not least, here are some twitter accounts you should follow to keep up with development news, including updates with Handlebars:

  • @handlebarsjs: The official Handlebars account

  • @wycats: Yehuda Katz's twitter account

  • @GabrielManricks: My own personal account