I had a look at this post but it does not come up with a solution: Register Assemble Handlebars Helpers
I want to register all the helpers in https://github.com/assemble/handlebars-helpers to my Express 4 application running express-handlebars.
So far I've tried this but the helpers are not getting registered:
var express = require('express')
, app = express()
, exphbs = require('express-handlebars');
var hbs = exphbs.create({
extname: '.hbs',
defaultLayout: 'default',
layoutsDir: './lib/templates/layouts',
partialsDir: './lib/templates/partials'
helpers: require('handlebars-helpers') // Not registering correctly
});
How does this library work? I'm probably doing it wrong. Are you supposed to register one at a time or can you load the all helpers?
Try this:
var express = require('express')
, app = express()
, exphbs = require('express-handlebars')
, hbsHelpers = require('handlebars-helpers');
var hbs = exphbs.create({
//code...
});
hbsHelpers.register(hbs.handlebars, {});