CoffeAbuser
CoffeAbuser

Reputation: 476

Svg in pug syntax

I'm trying to show a svg icon on html page with pug syntax, but doesn't work

This is the code

span.icon
  svg(width="24px", height="24px")
    use(xlink:href="../../../images/svg/glass.svg")

Upvotes: 0

Views: 12979

Answers (2)

Zohid
Zohid

Reputation: 488

Add id="glassRoot" -> (#glassRoot) after glass.svg.

Upvotes: -2

ccprog
ccprog

Reputation: 21836

The <use> element cannot link to complete files, only to named fragments. There is a proposal to change this in the future, but for now, the root <svg> element in file glass.svg needs to have an id, lets say id="glassRoot". Then you can do

span.icon
  svg(width="24px", height="24px")
    use(xlink:href="../../../images/svg/glass.svg#glassRoot")

Upvotes: 6

Related Questions