Answer the question
In order to leave comments, you need to log in
Why doesn't interpolation work?
icon file:
mixin icon(iconName)
svg&attributes(attributes)
use(xlink:href='##{iconName}')
include ../icon/icon
mixin menu(menu)
nav.menu
each item in menu
a(href='##{item[0]}').menu__item= item[0]
+icon('#{item[1]}').menu__icon
include ../menu/menu
mixin header()
header
.menu
+menu(
[
["Home", "menu-home"],
["About", "menu-user"],
["Contact", "menu-email"]
]
)
<nav class="menu">
<a href="#Home" class="menu__item">Home</a>
<svg class="menu__icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="##{item[1]}"></use>
</svg>
<a href="#About" class="menu__item">About</a>
<svg class="menu__icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="##{item[1]}"></use>
</svg>
<a href="#Contact" class="menu__item">Contact</a>
<svg class="menu__icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="##{item[1]}"></use>
</svg>
</nav>
Answer the question
In order to leave comments, you need to log in
When passing a parameter to a mixin, it does not need to be interpolated, just pass the value of the variable:
mixin icon(iconName)
svg&attributes(attributes)
use(xlink:href='##{iconName}')
mixin menu(menu)
nav.menu
each item in menu
a(href='##{item[0]}').menu__item= item[0]
+icon(item[1]).menu__icon
mixin header()
header
.menu
+menu(
[
["Home", "menu-home"],
["About", "menu-user"],
["Contact", "menu-email"]
]
)
+header
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question