ruby-on-railserb

Adding a line break in an .each do loop in an ERB file


I have code in an .erb file that loops three titles and descriptions from a corresponding YAML document. I would like to add a line break before the second and third titles as they all run together (see the FAQ section in the attached screenshot). Is it possible to use <br> or &#13 somewhere to accomplish this?

<div class="row">
  <div class="col-sm-12">
    <% t('brand.welcome_paragraphs').each do |para| %>
      <%= sanitize para[:title]%>
      <%= sanitize para[:description] %>
    <% end %>
  </div>
</div>

enter image description here


Solution

  • <div class="row">
      <div class="col-sm-12">
        <% t('brand.welcome_paragraphs').each do |para| %>
          <%= sanitize para[:title] %>
          <%= sanitize para[:description] %>
          <br />
        <% end %>
      </div>
    </div>
    

    Or maybe another way with css styling

    <div class="row">
      <div class="col-sm-12">
        <% t('brand.welcome_paragraphs').each do |para| %>
          <p><%= sanitize para[:title] %></p>
          <p class="mb-4"><%= sanitize para[:description] %></p>
        <% end %>
      </div>
    </div>