You can try to export your helpers as a module, and then include them in your main app.js file
Something like that:
IN helpers/handlebars.js
function hbsHelpers(hbs) {
hbs.registerHelper("inc", function(value, options) {
return parseInt(value) + 1;
});
}
module.exports = hbsHelpers;
app.js( , ).
var hbs = require('express-handlebars');
require('./helpers/handlebars')(hbs);
?
express-handlebars docs, helpers/handlebars.js - :
function hbsHelpers(hbs) {
return hbs.create({
helpers: {
inc: function(value, options) {
console.log('reading it');
return parseInt(value) + 1;
}
}
});
}
module.exports = hbsHelpers;
, .
2:
My Bad, helpers:{} create() handelbars.js. , , , , .
app.js, , , , :
var exphbs = require('express-handlebars');
var handlebars = require('./helpers/handlebars.js')(exphbs);
app.engine('hbs', handlebars.engine);
app.set('view engine', 'hbs');