phptwigpinterestkuma

How to add a class within raw filter marks?


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


Solution

  • You could try to replace the <li> tags:

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

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