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
Post a Comment