M
M
Moe Green2015-10-14 14:20:32
Pug
Moe Green, 2015-10-14 14:20:32

How to make jade mixin for svg?

Good day!
I made this mixin:

mixin use(name)
  svg.name(role="img")
    use(xlink:href="#{svg}#name")

To use it this way:
ul
  li
    +use(pencil)

And to get this as a result:
<svg role="img" class="pencil">
  <use xlink:href="images/icons.svg#pencil"></use>
</svg>

But this is what I get as a result:
<svg role="img" class="name">
  <use xlink:href="images/icons.svg#name"></use>
</svg>

Am I doing something wrong? Tell!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Moe Green, 2015-10-14
@mQm

Solution of the problem:

mixin use(name)
  svg(class="#{name}" role="img")
    use(id="#{name}" xlink:href="#{svg}##{name}")

M
monochromer, 2015-10-14
@monochromer

Enclose the name in quotation marks
As a result

- var svg = "images/icons.svg" 

mixin use(name)
  svg.name(role="img")
    use(xlink:href="#{svg}##{name}")
      
+use("pencil")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question