I've rewritten my html code with rails content_tag
s and now I want to add if-statements to them.
Before I had:
<% if ... %>
<div class='...'>
...
</div>
<% end %>
Now I have 2 types of this block:
<%= content_tag(:div, ..., class: 'some_class') if ... %>
This works ok. But when I try to add if-statement to do-end
block it fails:
<%= content_tag(:div, class: 'some_class') if ... do %>
...
<% end %>
I'm seeing this, instead of div
content:
<div>{:class=>"some_class"}</div>
Thanks!
An IF statement is executed based on the occurrence of a certain condition. IF statements must begin with the keyword IF and terminate with the keyword END.
Use the END statement to terminate a BASIC program or a section of an IF statement, , or OPEN statement. An END statement is the last statement in a BASIC program; it indicates the logical end of the program.
You have to use like :
<%if ... %>
<%= content_tag(:div, class: 'some_class') do %>
...
<% end %>
<% end %>
Or using if statement after the block :
<%= content_tag(:div, class: 'some_class') do %>
...
<% end if .......%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With