I'm trying to use Ember in a Node + Express based project. I put client code under public/javascript and serve it using the index.jade
file that we have by default in every express
project. I need to use handlebars
template for my client views but I can't figure out how to do this. Where should I put my template files and how the node server will compile and serve them ? Thanks!
I like to use this library for the Handlebars templating with node.js + express.
https://github.com/donpark/hbs
Here are the steps to start using Handlebars in your node + express setup
Install the hbs npm module with
npm install hbs --save
Import the module and change the view engine to use hbs.
var hbs = require('hbs')
app.set('view engine', 'hbs');
(Optional) To use partials, you ll need to register partials.
hbs.registerPartials(__dirname + '/views/partials');
The files should be in the views folder with an extension of .hbs. You can change this if need be.
app.set('views', path.join(__dirname, '<your_folder_name>'));
Check here more for partial naming conventions https://github.com/donpark/hbs