Answers.Body: <pre><code>{% set text %}
      Here is some
      Text that spans
      multiple lines
  {% endset %}
  
  {% set textArray = text | split('\n') | filter %}
  
  {% for line in textArray %}
      &lt;span&gt;{{ line }}&lt;/span&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-22T18:23:32.420Z
Answers.Text: Brilliant. Exactlay what I needed! Cheers, Trevor. 
Answers.UserDisplayName: Jay
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-22T17:18:50.867Z
Answers.LastActivityDate: 2018-08-22T17:18:50.867Z
Answers.UserDisplayName: Trevor Davis
Answers.Body: <p>I've made a little macro for this:</p>
  
  <pre><code>{% macro splitText(text) %}
    {% set text = text|nl2br|raw %}
    {% set text = '&lt;span class="split_text"&gt;' ~ text|replace('&lt;br /&gt;', '&lt;/span&gt; &lt;span class="split_text"&gt;') ~ '&lt;/span&gt;' %}
    {{ text|raw }}
  {% endmacro %}
  </code></pre>
  
  <p>You may need to tweak it a bit, but this is what worked for me.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-22T18:23:12.353Z
Answers.Text: Perfectly good answer. Ended up going with Trevor's below because I liked the control of the forloop. Gave me access to 'loop.index' in there, too. Thanks though, Will!
Answers.UserDisplayName: Jay
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-22T19:27:18.053Z
Answers.Text: Makes sense to me. I like that solution better, too :)
Answers.UserDisplayName: Will Browar
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-22T16:48:40.930Z
Answers.LastActivityDate: 2018-08-22T16:48:40.930Z
Answers.UserDisplayName: Will Browar
Body: <p>Building on this question here: <a href="https://craftcms.stackexchange.com/questions/2830/create-line-breaks-from-text-field/2834">Create line breaks from text field</a></p>
  
  <p>What approach would be best for breaking a multi line plain text field into multiple single lines to be used as:</p>
  
  <pre><code>&lt;span&gt;{{ textfield.lineOne }}&lt;/span&gt;
  &lt;span&gt;{{ textfield.lineTwo }}&lt;/span&gt;
  &lt;span&gt;{{ textfield.lineThree }}&lt;/span&gt;
  </code></pre>
  
  <p>At the moment, my approach is to use a Matrix for the user to be able to add individual lines, but I'd much rather I was able to present the client with a multiline text field and rework them in the template.</p>
  
Tags: <templating><plaintext>
Title: How to create single lines from a plain text field with line breaks
ThreadText: # How to create single lines from a plain text field with line breaks
  
  (Asked by: username_0 on 2018-08-22)
  
  Building on this question here: [Create line breaks from text field](https://craftcms.stackexchange.com/questions/2830/create-line-breaks-from-text-field/2834)
  
  What approach would be best for breaking a multi line plain text field into multiple single lines to be used as:
  
  ```
  <span>{{ textfield.lineOne }}</span>
  <span>{{ textfield.lineTwo }}</span>
  <span>{{ textfield.lineThree }}</span>
  
  ```
  
  At the moment, my approach is to use a Matrix for the user to be able to add individual lines, but I'd much rather I was able to present the client with a multiline text field and rework them in the template.
  
  **Tags:** templating, plaintext
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-08-22. Score: 3 | Accepted answer
  
  ```
  {% set text %}
      Here is some
      Text that spans
      multiple lines
  {% endset %}
  
  {% set textArray = text | split('\n') | filter %}
  
  {% for line in textArray %}
      <span>{{ line }}</span>
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Brilliant. Exactlay what I needed! Cheers, username_1.   
  
  ---
  
  ### Answer by username_2 on 2018-08-22. Score: 2
  
  I've made a little macro for this:
  
  ```
  {% macro splitText(text) %}
    {% set text = text|nl2br|raw %}
    {% set text = '<span class="split_text">' ~ text|replace('<br />', '</span> <span class="split_text">') ~ '</span>' %}
    {{ text|raw }}
  {% endmacro %}
  
  ```
  
  You may need to tweak it a bit, but this is what worked for me.
  
  > **Comments:**
  > **username_0**: Perfectly good answer. Ended up going with username_1's below because I liked the control of the forloop. Gave me access to 'loop.index' in there, too. Thanks though, username_2!  
  > **username_2**: Makes sense to me. I like that solution better, too :)  
  
  ---
  
  