P
P
pavvel22018-04-19 11:46:22
Twig
pavvel2, 2018-04-19 11:46:22

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
  
   }}

Can you suggest other ways to accomplish this task.
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2018-04-19
@Austin_Powers

Try like this:

'<li class="remark__item item"><p class="remark__text"><span class="remark__label">' ~ loop.index ~ '</span>'

P
pavvel2, 2018-04-19
@pavvel2

Added a general task description:
https://craftcms.stackexchange.com/questions/25754...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question