I am using expressjs with handlebars as templating engine with following code in Webstorm IDE with express generator.There is no visible handlebars require in the code (I guess express generator has it someplace else which is not visible)
var app = express();
.
.
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
How do i use registerHelper on serverside in this situation ?
My other renderings and partials are working.So handlebars is doing its work.Its just that registerHelper seems to be cause of worry.
I think
express-generator
just setsview engine
tohbs
only. To configure thehbs
engine, you have to useexpress-handlebars
.e.g.
And, helpers.js
Source: http://www.codyrushing.com/using-handlebars-helpers-on-both-client-and-server/
I have given a thumbs up to @Mukesh Sharma as he very nearly had the syntax that worked for me and really led me to it.
He is doing a bit more to make it work for the front end I believe. All I needed was the following
Then I have a simple file I include from where I have helper stuff .
No need to pass or import handlebars-express - including the simple object of helper functions as part of the exhbs options hash under helpers lets express hbs do all of the registering by it's own approach.