Reputation: 9682
coming from Django I am wondering how rails people think about <%= %> vs <% %>
From what I see here <%= tag.title %> displays information that's already present like attributes of the obj, like the {{ }} in django, and <% %> always does stuff, like an each loop or if statement, like the {% %} in django.
If that statement fully accurate, or is there a finer line I missed? Thanks
Upvotes: 0
Views: 126
Reputation: 7327
Yeah you've basically got it down.
<% %>
Will run ruby code without displaying it
<%= %>
Will display the information to the screen
<%# %>
Will comment out ruby code in your view
Here's just a simple example
<% @users.each do |user| %>
<%= user.email %>
<% end %>
This question may help you as well.
Upvotes: 2