views:

98

answers:

3

Hi friends,

I need to know what is the difference between <%= expression %> and <%= expression -%> on rails, please help me to make good foundation on Ruby On Rails

+11  A: 

The '-%>' means, that no linebreak will be appended to the output of the expression. It's usefull if you want to control the amount of whitespace you have in the generated HTML but do not want to put all the code in a single line.

Tomas Markauskas
Thanks friend this answer will be useful for me
Senthil Kumar Bhaskaran
In that case, it's good form to mark this answer as "Accepted" so the answerer gets the credit for it.
SFEley
+1  A: 

I say don't bother with '-%>' If you are using layouts and partials with your views it is difficult control the output anyway, things like indentation will likely be messed up. Just focus making your ERb look good and don't worry too much what the generated output looks like.

Daniel Kristensen
thanks for ur comments
Senthil Kumar Bhaskaran
+2  A: 

As mentioned before, the -%> is used to control output whitespace. I you're at all concerned with how your HTML looks, use HAML. HAML is way more clear and readable when coding and it generates clear, valid formatted HTML. No more forgotten close tags!

Ariejan