-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
  • 25,146
  • 28
  • 91
  • 166

1 Answers1

7

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

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

Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145
Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87