1

Could someone explain the difference between using <%= some_ruby_code %> and <% some_other_ruby_code %>

I'm aware that they're not equivalent but can't find a good explanation as to why. Thanks in advance.

2 Answers2

1

In ERB (Embedded Ruby), using <%= %> will both evaluate and render the evaluated Ruby within your markup, whereas just using <% %> will only evaluate the enclosed expression, and will not print anything to the erb file.

Hope it helps!

Zoran
  • 3,930
  • 2
  • 19
  • 31
0

In other words, with <%= %> you execute ruby code and print the output. Using <% %> is only necessary to run the ruby code.

To clarify, this is Emebedded Ruby which you use for views pages on Rails. This might helpful for you: https://docs.puppetlabs.com/puppet/latest/reference/lang_template_erb.html

Fercell
  • 111
  • 3