-3

I have a form in ruby html:

<%= form_for :article do |f| %>
<p>
  <%= f.label :title %><br>
  <%= f.text_field :title %>
</p>
<p>
  <%= f.label :text %><br>
  <%= f.text_area :text %>
</p>

<p>
  <%= f.submit %>
</p>
<% end %>

Attention

The last line of code:<% end %>, why it is not <%= end %>?

whats the different function with them? and if use <%= end %>, there will get this syntax error.

Community
  • 1
  • 1
aircraft
  • 16,211
  • 16
  • 74
  • 135

1 Answers1

6

<% %> will evaluate the code, but will not print the output.

<%= %> will evaluate the code AND print the output.

Andrey Deineko
  • 47,502
  • 10
  • 90
  • 121
Richard Hamilton
  • 22,314
  • 9
  • 45
  • 77