Difference between “<%=” and “<%” when mixing ruby with html?

后端 未结 2 460
再見小時候
再見小時候 2021-01-28 05:28

I\'m learning Rails, and i\'m doing a exercise which i have to mix some html with ruby in a view file.

What is the main difference between \" <%= #code %> \" and \" &

2条回答
  •  一整个雨季
    2021-01-28 05:53

    <%= 1 + 2 %> will evaluate AND display the result. In this case, you should see 3 in your view.

    <% 1 + 2 %> will evaluate but will not display the result in the view. In this case, you will not see 3 in your view.

提交回复
热议问题