Answers.Body: <p>You'll want to <a href="https://twig.symfony.com/doc/2.x/filters/split.html" rel="nofollow noreferrer">split</a> on the line breaks, then loop through the resulting array...</p>
  
  <pre class="lang-html prettyprint-override"><code>{% for ingredient in listOfIngredients|trim|split('\n') %}
      &lt;li&gt;{{ ingredient }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-21T04:55:57.490Z
Answers.LastActivityDate: 2017-08-21T04:55:57.490Z
Answers.UserDisplayName: Lindsey D
Body: <p>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 <code>&lt;li&gt;Whatever is on that line&lt;/li&gt;</code></p>
  
  <p>So going from this:</p>
  
  <p><a href="https://i.sstatic.net/ajxdM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ajxdM.png" alt="enter image description here"></a></p>
  
  <p>Into this:</p>
  
  <p><a href="https://i.sstatic.net/vf1Sm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vf1Sm.png" alt="enter image description here"></a></p>
  
  <p>Thanks!</p>
  
Tags: <templating><field><twigextension>
Title: How to get a list item <li> using a plain text field every time I hit enter
ThreadText: # How to get a list item <li> using a plain text field every time I hit enter
  
  (Asked by: username_0 on 2017-08-21)
  
  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](https://i.sstatic.net/ajxdM.png)](https://i.sstatic.net/ajxdM.png)
  
  Into this:
  
  [![enter image description here](https://i.sstatic.net/vf1Sm.png)](https://i.sstatic.net/vf1Sm.png)
  
  Thanks!
  
  **Tags:** templating, field, twigextension
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-21. Score: 4 | Accepted answer
  
  You'll want to [split](https://twig.symfony.com/doc/2.x/filters/split.html) on the line breaks, then loop through the resulting array...
  
  ```html
  {% for ingredient in listOfIngredients|trim|split('\n') %}
      <li>{{ ingredient }}</li>
  {% endfor %}
  
  ```
  
  
  ---
  
  