Sails app using handlebars templating engine
Step-by-step
- create a new app
sails new sailsjs-handlebars-app
- install handlebars
npm install handlebars --save
- update configured templating engine
// config/views.js
// ...
engine: 'handlebars',
// ...
- change extension of your view files
cd views && for old in *.ejs; do mv $old `basename $old .ejs`.handlebars; done && cd ..
- update content of existing view files, so that they reflect handlebars syntax
// views/layout.handlebars
// views/homepage.handlebars
// views/403.handlebars
// views/404.handlebars
// views/500.handlebars
- change extension used inside
sails-linker.js
// tasks/config/sails-linker.js
// example
// ...
'views/**/*.ejs': require('../pipeline').jsFilesToInject
// to
'views/**/*.handlebars': require('../pipeline').jsFilesToInject
// ...
Resource:
- Sails
- running the app:
npm install && sails lift
- Using .hbs instead of .handlebars