Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Created October 10, 2013 12:17
Show Gist options
  • Save craigmdennis/6917403 to your computer and use it in GitHub Desktop.
Save craigmdennis/6917403 to your computer and use it in GitHub Desktop.
Iterate over a breadcrumb with Jade to include 'current' page and disabled states after the current page.
//- The breacrumb text and links
-var menu = { 'item 1': '#', 'item 2': '#', 'item 3': '#', 'item 4' : '#', 'item 5': '#'}
//- Allow us to override this within a child template
block vars
-var selected = 'item 1' //- default
-var enabled = true //- Use links until changed to disabled, then use divs
ol.breadcrumb
each val, key in menu
li.breadcrumb-item
if selected === key
-var enabled = false
div.breadcrumb-inner.breadcrumb-current
span.breadcrumb-text #{key}
else
if enabled === false
div.breadcrumb-inner
span.breadcrumb-text #{key}
else
a.breadcrumb-inner.breadcrumb-link(href=val, title=key)
span.breadcrumb-text #{key}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment