I have this code with a check
method that returns true or false
<%= link_to path, format: 'js' do %>
<i class="<%= check ? "close\"></i>Unfollow member" : "open\"></i>Follow member></i>" %>
<% end %>
</div>
<div class="list-group list-normal m-b-none">
but this outputs
<i class="close"></i>Unfollow member
</a> </div>
<div class=" list-group="" list-normal="" m-b-none"="">
</i>
How can it be ? (I don't want to repeat the check
statement inside and outside the i
tag)
I think following will be more readable:
<% if check %>
<i class="close">Unfollow member</i>
<% else %>
<i class="open">Follow member></i>
<% end %>
Update:
To make it one liner:
<%= check ? "<i class='close'>Unfollow member</i>" : "<i class='open'>Follow member></i>" %>
<%= link_to path, format: 'js' do %>
<i class="<%= check ? "'close'></i>Unfollow member" : "'open'></i>Follow member>" %></i>
<% end %>
I did not try. But if may works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.