I'm trying to understand how jade template engine works. I would like to open one of my .jade file fro开发者_开发技巧m the route in my node.js + express.js server passing some variable (for example if a user logs in, I would like to greet him). I know it's possible because I've been pointed to jade for that, but I can't find a good example on jade's github about that.
Does anyone of you already solved this and can help me? Thanks.
route:
app.get('/login', function(req, res){
var usr = new User({username: 'myname'})
res.render('login/success', {
title: 'Welcome',
user: usr
});
});
login/success.jade:
h2 Welcome #{user.username}
or any number of other options. see https://github.com/visionmedia/jade for more help with the templating language.
精彩评论