Reputation: 107
I am looping through items using @each, and I want to start with index 1 and not 0. I have tried something like
var Handlebars = require('handlebars');
Handlebars.registerHelper("inc", function(value, options)
{
return parseInt(value) + 1;
});
and then
{{inc @index}}
But when I am loading the page, it says
Error: Missing helper: "inc"
What is another way to do it?
Upvotes: 0
Views: 2749
Reputation: 11
in your app.js :
app.engine('.hbs', expressHbs({ defaultLayout: 'layout', extname: '.hbs', helpers: {
inc: function(value, options){
return parseInt(value) + 1;
}
} }));
Upvotes: 1