Node.js Express + Jade (Active Class on Lined Item) -


how set active tag class depending on url?

in example below '/' (home) set active.

.nav-collapse.collapse   ul.nav.top-2     li.active       a(href='/') home     li     li       a(href='/about')     li     li       a(href='/contact') contact     li 

would better inject page identify active page?

here's do, hexacyanide's example,

res.render('/path', {   path: req.path }); 

..and in layout.jade:

.nav-collapse.collapse   ul.nav.top-2     li(class=path=='/'?'active':undefined)       a(href='/') home     li(class=path=='/about'?'active':undefined)       a(href='/about')     li(class=path=='/contact'?'active':undefined)       a(href='/contact') contact 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -