6

Possible Duplicate:
Difference between -%> and %> in rails

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

Community
  • 1
  • 1
Senthil Kumar Bhaskaran
  • 7,371
  • 9
  • 43
  • 56

3 Answers3

11

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
  • 11,496
  • 2
  • 33
  • 35
2

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
  • 10,910
  • 6
  • 43
  • 40
1

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
  • 1,364
  • 8
  • 6