This question already has an answer here:
这个问题在这里已有答案:
- How to comment lines in rails html.erb files? [duplicate] 3 answers
- 如何在rails html.erb文件中注释行? [重复] 3个答案
I understand that commenting in rails is done with '#' but if I try to comment out ERB tags, I always run into problems
我知道在rails中的注释是用'#'完成的,但是如果我试着注释掉ERB标签,我总会遇到问题
<%= link_to "Make default", make_default_admin_state_path(state) %>
Where would you put the '#' on this code?
你会在这里把'#'放在这个代码上?
I tried to put it outside the <% and it did nothing. when I put it inside, there was an error message
我试图把它放在<%之外,它没有做任何事情。当我把它放在里面时,有一个错误信息
4 个解决方案
#1
49
<%#= link_to "Make default", make_default_admin_state_path(state) %>
<%# %>
is an ERB comment: the dangling =
makes no difference, and can be left in.
<%#%>是一个ERB评论:悬空=没有区别,可以留下来。
#2
14
Just now I wanted to just leave a block out of the template because it was currently useless, if that's the case I suggest:
刚才我想把一个块从模板中删除,因为它目前是无用的,如果是这样,我建议:
<% if false %>
this block of code won't give runtime errors..
<%= alm lkjsxajklla 10293 aslkj no problems! %>
<% end %>
#3
1
<!-- %= link_to "Make default", make_default_admin_state_path(state) % -->
#4
-1
you can do it like one the @Dominic Goet did.If you stuck from it you can try this one
你可以像@Dominic Goet那样做。如果你坚持下去就可以尝试这个
<%=# link_to "Make default", make_default_admin_state_path(state) % >
or
要么
< %#= link_to "Make default", make_default_admin_state_path(state) %>
#1
49
<%#= link_to "Make default", make_default_admin_state_path(state) %>
<%# %>
is an ERB comment: the dangling =
makes no difference, and can be left in.
<%#%>是一个ERB评论:悬空=没有区别,可以留下来。
#2
14
Just now I wanted to just leave a block out of the template because it was currently useless, if that's the case I suggest:
刚才我想把一个块从模板中删除,因为它目前是无用的,如果是这样,我建议:
<% if false %>
this block of code won't give runtime errors..
<%= alm lkjsxajklla 10293 aslkj no problems! %>
<% end %>
#3
1
<!-- %= link_to "Make default", make_default_admin_state_path(state) % -->
#4
-1
you can do it like one the @Dominic Goet did.If you stuck from it you can try this one
你可以像@Dominic Goet那样做。如果你坚持下去就可以尝试这个
<%=# link_to "Make default", make_default_admin_state_path(state) % >
or
要么
< %#= link_to "Make default", make_default_admin_state_path(state) %>