O'Reilly logo

Web Development with MongoDB and Node.js by Jason Krol

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

Handlebars Helpers

Handlebars supports the idea of helpers, which are special custom functions you can write to perform some special logic from within the template during runtime. A great example of a helper would be the date string formatter we've been using. Helpers can be registered globally and made available to every template file, or they can be defined per view and passed to the template on an as needed basis as a part of the ViewModel.

Global helpers

First, let's create a global helper that will be available to every Handlebars template we render. This global helper that you will create will be used to format a timestamp so that it is worded as to how long ago the event occurred. We will use this throughout our application for things such ...

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