2

I'm trying to get a list from a simple plain text field which will accept line breaks. I need to find a way to wrap an li tag around the content on that line. So everytime I hit enter, it wraps <li>Whatever is on that line</li>

So going from this:

enter image description here

Into this:

enter image description here

Thanks!

4

You'll want to split on the line breaks, then loop through the resulting array...

{% for ingredient in listOfIngredients|trim|split('\n') %}
    <li>{{ ingredient }}</li>
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.