Issue
I have a field in my settings.html
where I am expecting the user to input multiple paragraphs separated by two newline characters. I would like to split this string of input into an array of strings, each representing a paragraph.
I would like to do something like this:
{% assign paragraphs = settings.intro | split: '\n' %}
{% for paragraph in paragraphs %}
<p>
{{ paragraph }}
</p>
{% endfor %}
I can't seem to figure out how to refer to the newline character in Liquid. How can I go about doing this? Is there some kind of work around?
Solution
Try this:
{% assign paragraphs = settings.intro | newline_to_br | split: '<br />' %}
{% for paragraph in paragraphs %}<p>{{ paragraph }}</p>{% endfor %}
Answered By - Josh Brown Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.