hey smart people want me!
im nodejs beginner , want use handlebars template engine... first nodejs application, follow guide: https://www.youtube.com/watch?v=m5ribwppipw
i use cloud9 ide..
i have 1 js file realy everything:
var express = require('express'); var app = express(); var hbs = require('express3-handlebars'); app.engine = ('handlebars', hbs({defaultlayout: 'layout'})); app.set = ('view engine', 'handlebars'); app.get('/', function (req,res){ res.render('index'); }); app.use('/views',express.static('views')); app.listen(process.env.port || 3000, process.env.ip || "0.0.0.0");
im doing guide refernce me do... this folder tree:
update: error get.. forgot put here:
/home/ubuntu/workspace/node_modules/express/lib/application.js:421 return boolean(this.set(setting)); ^
typeerror: this.set not function @ eventemitter.enabled (/home/ubuntu/workspace/node_modules/express/lib/application.js:421:23) @ eventemitter.lazyrouter (/home/ubuntu/workspace/node_modules/express/lib/application.js:139:27) @ eventemitter.methods.foreach.app.(anonymous function) [as get] (/home/ubuntu/workspace/node_modules/express/lib/application.js:478:10) @ object. (/home/ubuntu/workspace/server.js:8:5) @ module._compile (module.js:409:26) @ object.module._extensions..js (module.js:416:10) @ module.load (module.js:343:32) @ function.module._load (module.js:300:12) @ module.runmain [as _ontimeout] (module.js:441:10) @ timer.listontimeout (timers.js:92:15)
fix these lines :
app.engine('handlebars', hbs({defaultlayout: 'layout'})); app.set('view engine', 'handlebars');
and another, change layout.hbs
layout.handlerbars
Comments
Post a Comment