S
S
Sergey Burduzha2019-04-09 13:50:35
Pug
Sergey Burduzha, 2019-04-09 13:50:35

How to pass class to pug or jade mixin?

Hello.
I want to create a mixin, but it doesn't work.
The result should be like this

svg.icon-location
    use(xlink:href="#location")

mixin I write like this
svg.= class
    use(xlink:href="#= icon")

and include in this way
+icon('icon-location', 'location')
There are errors in mixins, there are two simple examples in the documentation, but I did not find how to transfer classes and how to write in an attribute where there is # and quotes.
Tell me how to solve.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Ionenko, 2019-04-09
@serii81

mixin value(name)
  span(class="value " + name)= name
mixin icon(icon, location)
  svg(class="" + icon)
    use(xlink:href="#" + location )
 
.header
  p Text
  +value('example text')
  +icon('icon-location', 'location')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question