Answer the question
In order to leave comments, you need to log in
How to implement an active menu item using jade capabilities?
Hello, I'm setting up a large project where you can repeat elements, so I put them in separate files and include them in the right place. But what about active menu items? Are there any tricks?
Answer the question
In order to leave comments, you need to log in
I would do it in js, but you can do it like this:
stackoverflow.com/questions/15719660/jade-change-a...
parent.jade
doctype 5
html
block link
-var selected = 'home'; //default
-var menu = { 'home': '/home', 'blog': '/blog', 'contact': '/contact' };
body
nav
ul
each val, key in menu
li
if selected === key
a.selected(href=val, title=key)= key
else
a(href=val, title=key)= key
extends parent
block link
-var selected = 'blog';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question