javascript - Node.js+Handlebars+Express how to reference the handlebars templates? -


i'm relative new node & express, handlebars templates i've never used before , trying reference them in node app.js keep on getting following error

property 'engine' of object # not function

this code:

app.configure(function () {         app.set('views', __dirname+ '/views');         app.set('port', 3000);         app.set('view engine', 'handlebars');         app.use(handlebarslayout);         app.use(express.static(path.join(__dirname, 'public')));         app.use(app.router);     });      // routes     app.get('/', function (req, res){          var data = {             title: "node + handlebars",             body: "hello world!"         }          res.render('index', data);     });      http.createserver(app).listen(app.get('port'), function () {         console.log("express server listening on port " + app.get('port'));     }); 

any appreciated.

thanks, tom

for interested found post useful , helped solve issue.

https://stackoverflow.com/a/14346094/911553

i installed consolidate (npm install consolidate) , did following:

var engines = require('consolidate')  app.configure(function () {         app.set('views', __dirname+ '/views');         app.set('port', appconfig.appconfig.express.port);          app.set('view engine', 'html');         app.set("view options", { layout: true });         app.engine('.html', engines.handlebars);         app.use(app.router);     });  // routes     app.get('/', function (req, res){          var data = {             title: "node + handlebars",             body: "hello world!"         }          res.render('index', data);     });     

and pages render handlebars templates.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -