Switch template engine to Handlebars
I am a huge fan of using Handlebars
and think its nicer to work with it on the backend with an express project. Switching it out from Jade
to Handlebars
is really simple.
Install Express-Handlebars
The npm handlebars package is express-handlebars
. Add the following to your package.json
dependencies list:
"express-handlebars": "*"
"*"
will pull the latest version, feel free to substitute this with a specific version number if you wish. Now just change app.js
to use the handlebars engine instead of Jade.
Switch template engines
Thats all! Now under {project_root}/views
you can put your handlebars templates. By default the file extension is .handlebars
.