F
F
flafy42019-10-27 15:54:39
JavaScript
flafy4, 2019-10-27 15:54:39

How to write SVG image content to variable, es6, gulp?

Tell me how to write the svg code from a file to a variable? To get something like:

const mysvg = '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">.........</svg>'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
McBernar, 2019-10-27
@McBernar

fs.readfile
Google the fs module for node. This is from the standard libs.

D
dmax1447, 2019-10-27
@dmax1447

If you need to get an existing node in this form, then you can use, for example, the outerhtml method

// HTML:
// <div id="d"><p>Content</p><p>Further Elaborated</p></div>

d = document.getElementById("d");
console.log(d.outerHTML);

// строка '<div id="d"><p>Content</p><p>Further Elaborated</p></div>'
// выведена в окно консоли

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question