Answer the question
In order to leave comments, you need to log in
Why doesn't loop.index work with replace?
Good afternoon.
I'm trying to set up the replacement of tags for markdown through replace, everything works except for the {{ loop.index }} tag,
please tell me how to properly set up {{ loop.index }} for correct work?
{{ block.markdownContent|markdown
|replace('<p>', '<p class="section__paragraph text">')
|replace('<h2>', '<h2 class="section__title title">')
|replace('<a ', '<a class="link link-color"')
|replace('<ul>', '<ul class="attention">')
|replace('<li>', '<li class="attention__item"><p class="attention__text">')
|replace('</li> ', '</p></li>')
|replace('<ol>', '<ol class="remark list">')
|replace('<li>', '<li class="remark__item item"><p class="remark__text"><span class="remark__label">{{ loop.index }}</span>')
|replace('</li> ', '</p></li>')|raw
}}
Answer the question
In order to leave comments, you need to log in
Try like this:
'<li class="remark__item item"><p class="remark__text"><span class="remark__label">' ~ loop.index ~ '</span>'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question