jade if behaving inconsistent

alx-r

New Member
I am using expressjs, I have in my app the following: \[code\]app.get('/profile',index.profile);app.get('/',index.home);\[/code\]and in layout.jade\[code\]...if typeof(username)!=='undefined' li: a(href='http://stackoverflow.com/logout') Log Out else li: a(href='http://stackoverflow.com/register') Register...\[/code\]My routing code is the following:\[code\] exports.home = function(req,res){if (typeof req.session.username == 'undefined') res.render('login',{title:'PageTitle'});else res.redirect('/profile'); };exports.profile = function(req,res){var show_devices = function(username,dev){ res.render('home',{title:'Pagetutle', username: username,some other data..});}if (typeof req.session.username == 'undefined') res.redirect('/'); ...\[/code\]Here is my logout\[code\] exports.logout = function(req,res){req.session.destroy();res.redirect('/'); };\[/code\]The first time I start my server I get in the list \[code\]Register\[/code\], when I log in I gent \[code\]Log Out\[/code\], but when I log out I also get \[code\]Log Out\[/code\]. As if the \[code\]username\[/code\] somehow would have survived there. How can I remove from the jade namespace the \[code\]username\[/code\] variable - I think that's my problem.
 
Top