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

How can I fetch data from a web server in an android application? -

Change php variable from jquery value using ajax (same page) -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -