Answer the question
In order to leave comments, you need to log in
How in Pug to shove a span into a string that is the value of an object?
How to write correctly in this case, so that in the end in HTML it turns out like this?:
<div class="block__title">second<span class="accent">title</span></div>
-
var obj = [
{title: 'first title', text: 'first text'},
{title: 'second #[span.accent title]', text: 'second text'},
{title: 'third title', text: 'third text'}
]
mixin features(title, text)
.block
.block__item
img.block__img(src="/img/block/1.jpg")
.block__title= title
p.block__capture= text
each val, index in obj
+features(val.title, val.text)
Answer the question
In order to leave comments, you need to log in
In general, you can write html directly in values, and to output unescaped code, write !=
-
var obj = [
{title: 'first title', text: 'first text'},
{title: 'second <span class="accent">title</span> ', text: 'second text'},
{title: 'third title', text: 'third text'}
]
mixin features(title, text)
.block
.block__item
img.block__img(src="/img/block/1.jpg")
.block__title!= title
p.block__capture= text
each val, index in obj
+features(val.title, val.text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question