boby lapointe
boby lapointe

Reputation: 535

How do i write my erb file without skipping lines

i have the t function witch return some text.

so on my erb file i have something like that:

<%= t 'content1' %> 
<%= t 'content2' %>

and the html output is something like that:

"text of the content 1"
"text of the content 2"

I would like to output something like that:

"text of the content 1" "text of the content 2"

thanx

Upvotes: 0

Views: 202

Answers (4)

Dwight Spencer
Dwight Spencer

Reputation: 1596

Erb is a little overrated compared to other template languages out there. But, the good thing is it allows you to control the output. As @DMG pointed out add a '-' to your tags but there is also another point I wanted to show.

<%- method(...) -%>

Will not show any lines on output. While this will create a blank line:

<% method(...) -%>

Just something to keep in mind if your writing templates for scripts, unit tests, rake task, or anything else outside of Rails/ActionView

Upvotes: 1

DGM
DGM

Reputation: 26979

ERB has an option in the closing tag whether to have a newline after it. Just add a dash:

<%= t 'content1' -%> 
<%= t 'content2' %>

Upvotes: 1

Kibet Yegon
Kibet Yegon

Reputation: 2823

just do:

<%= "#{t('content1')}#{t('content2')}" %>

Upvotes: 0

Salil
Salil

Reputation: 47472

<%= "#{t('content1')} #{t('content2')}" %> 

Upvotes: 0

Related Questions