R
R
rurobud2017-07-04 16:44:53
HTML
rurobud, 2017-07-04 16:44:53

Pug and SVG - how to be?

What about using inline SVG in Pug/Jade?
There's an xml code there.
This is a serious block.
Damn, I've been working in Pug for a couple of weeks, translated a lot of things, but if you can't stupidly use SVG, then everything is in the trash. I'm shocked.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Davydov, 2017-07-04
@space_pancake

html2jade.org
html2jade.aaron-powell.com

I
Igor Koch, 2017-07-04
@amux

doctype html
html
  head
  body
    svg(width="200px", height="230px", version="1.1", xmlns="http://www.w3.org/2000/svg", xmlns:xlink="http://www.w3.org/1999/xlink")
      circle/(cx="100", cy="100", r="100", fill="#000")
      circle/(cx="100", cy="100", r="95", fill="#ff0")

or
include path/to/icon.svg

N
Nikolay Semenov, 2017-07-04
@nickola105

Try a Mixin

mixin icon(name, url)
  - mod = mod || ''
    a(href="#{url}" class="#{name}_link")
      svg(class="icon icon-" + name)
        use(xlink:href="/assets/img/sprite.svg#" + name)

this is a link icon mixin, for an svg sprite... if the link is not needed just rewrite the mexin, the main idea is clear. instead of a sprite, just write name and it will take the corresponding svg from the folder
use(xlink:href="/assets/img/" + name + ".svg"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question