-
-
Save mfd/022c7f7263a9b3aca3b4d262cdf0df50 to your computer and use it in GitHub Desktop.
Enhanced Jade templates - BEM blocks + pass some data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LIVE EXAMPLE: http://codepen.io/orlovmax/pen/PZRXaN?editors=1000 | |
// Define navigation mixin | |
mixin nav(args) | |
- items = args.items || {} | |
- active = args.active || {} | |
- nav = args.nav || {} | |
- list = args.list || {} | |
- item = args.item || {} | |
- item_active = args.item_active || {} | |
- link = args.__link || {} | |
- link_active = args.link_active || {} | |
//- Build menu and highlight active item | |
nav.nav&attributes(nav) | |
ul.nav__list&attributes(list) | |
each url, name in items | |
if name === active | |
li.nav__item&attributes(item_active) | |
a.nav__link&attributes(link_active)= name | |
else | |
li.nav__item&attributes(item) | |
a.nav__link(href=url)&attributes(link)= name | |
//- Call mixins with parameters | |
+nav({ | |
active: 'Home', | |
items: { | |
'Home': 'index.html', | |
'Services': 'services.html', | |
'Blog': 'blog.html', | |
'Contacts': 'contacts.html' | |
}, | |
nav: { | |
class: 'js-nav is-opened', | |
role: 'navigation' | |
}, | |
item_active: { | |
class: 'is-active' | |
}, | |
link_active: { | |
class: 'is-active' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment