Skip to content
Jesper Lindström edited this page Jun 8, 2014 · 1 revision

Helpers are located in app/helpers/*.js and are merely simple functions that do basic things such as formatting data. In our example application, app.helpers.timeAgo(timestamp) is a helper that converts a date string into relative time (like "5h ago").

app.helpers.myHelper = function(text) {
	// Do something with text

    return text;
};

Helpers may also register themselves as Handlebars helpers, accessed via {{myHelper 'Example text'}} in Handlebars templates.

Handlebars.registerHelper('myHelper', app.helpers.myHelper);
Clone this wiki locally