How to add a class within raw filter marks?

52 views Asked by At

In the Kuma CMS, our users create list items for instructions. There are titles and other text as well. Mostly h2, ul/li, and p elements.

It gets added to the page with {{ resource.list|raw }}

Is there a way to add a class to only LI tags within the {{ resource.list|raw }}?

1

There are 1 answers

1
tino.codes On BEST ANSWER

You could try to replace the <li> tags:

{{ resource.list|replace({'<li>': '<li class="your-class">'})|raw }}

Working example: https://twigfiddle.com/svajsh