L
L
lavezzi12015-09-23 17:46:11
css
lavezzi1, 2015-09-23 17:46:11

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

1 answer(s)
J
jlekapb, 2015-09-23
@lavezzi1

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

child.jade
extends parent

block link
  -var selected = 'blog';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question