Handlebars template with Can.js

I have a handlebars.js template and have created helpers. These work perfectly as expected when the handlebars template is compiled in the normal way. However, when trying to use Can.js ‘can.map’ for data and ‘can.view’ to render the template, e.g.

var mappedData = new can.Map(data);
var template = can.view("#list", mappedData);

The helpers are obviously not registered and do not work with the template (I need can.js for live data binding). Could anyone offer guidance on registering the following template to work with can.js templates:

Handlebars.registerHelper('dateFormat', function (context, block) {
    if (window.moment) {
       var f = block.hash.format || "MM-DD-YYYY";
        return moment(context).format(f);            
    } else {
        return context;   

Many thanks in advance!

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.