I'm not sure why "\n\n" is not adding two line breaks in my code below:
<%= (getparagraph(@geography, "geography")+"\n\n") if @geography != "Other" %>
To clarify the method getparagraphs simply returns a paragraph of text. I'm trying to add two line breaks within the Ruby code without having to use <br/>
Any ideas? Everything I've read implies that it should work.
Your helper has "paragraph" in its name so maybe you should wrap it in a paragraph and use CSS to add the appropriate spacing around the paragraph:
<% if @geography != "Other" %>
<p>
<%= getparagraph(@geography, "geography") %>
</p>
<% end %>
You could always add a special class to the <p>
if you need an extra spacing after this:
<% if @geography != "Other" %>
<p class="geo-chunk">
<%= getparagraph(@geography, "geography") %>
</p>
<% end %>
and then in your CSS:
.geo-chunk {
margin-bottom: 2em; /* Or whatever works */
}
And if this is to appear inside another <p>
then you'd need to re-arrange the HTML a bit as you can't put a block element inside a <p>
:
<div>
<!-- The old <p> content ... -->
<% if @geography != "Other" %>
<div class="geo-chunk">
<%= getparagraph(@geography, "geography") %>
</div>
<% end %>
</div>
You're outputting HTML; whitespace is largely ignored upon rendering.
Use <br/>
tags instead, and .html_safe
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With