M
M
MyQuestion2021-05-21 22:01:31
JavaScript
MyQuestion, 2021-05-21 22:01:31

Gulp-webp-html: how to make a line break when outputting code in html?

Good afternoon!

The function inside gulp-webp-html returns this line:

return '<picture><source srcset="' + url + '" type="image/webp">' + imgTag + '</picture>';

My js, to put it mildly, is not very good... I tried, as in VSCode snippets, to add a tab "\t", the maximum I achieved was a space in html.
I need to convert the string, when outputting html, to the form:
<picture>
   <source srcset="url" type="image/webp">' 
   <img src="" width="" height="" alt="">
</picture>


How to break the code generated in html into tabs in js?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yury Kuchinsky, 2021-05-30
@kucher32

return '<picture><source srcset="' + url + '" type="image/webp">\n' + imgTag + '</picture>';

U
Uncle Tolya, 2021-05-30
@sh4rov

as an option try to use gulp-format-html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question