Open ghosh opened 9 years ago
Not sure if I'm late to the party, but you can do the following:
var exhbs = require("express-handlebars"),
handlebarsConfig = { ... };
hbs = exhbs.create(handlebarsConfig);
require("handlebars-helpers").register(hbs.handlebars, {});
app.engine(".hbs", hbs.engine);
I hope this helps.
Wish I would have seen your comment before I spent an hour figuring out that hbs.handlebars is the instance to pass into handlebars-helpers.
I've now run into another incompatibility. It looks like hbs.handlebars.partials isn't populated by express-handlebars. I'm guessing this is for performance reasons, or dev/prod differentiation? In any case, handlebars-helpers tries to reference that collection for {{#extend}}, which is empty.
Linking the issues on the repos: https://github.com/assemble/handlebars-helpers/issues/205#issuecomment-174327705
Here's a quick snippet showing the issue:
hbs.getPartials().then(function (partials) {
console.log(partials);
console.log(hbs.handlebars.partials);
// Outputs:
// => { 'foo/bar': [Function], title: [Function] }
// => {}
});
I am talking about this library specifically - https://github.com/assemble/handlebars-helpers
I tried something like this, could not get it to work.
Alternatively how can I use express-handlebars to render markdown content?
Sorry, I'm new to node, still figuring things out.