2010-08-07 49 views

回答

6

如果我理解正确的问题,你问的Ruby/Rails评论VS HTML注释......这给你的观点一试:

<!-- This is an HTML comment and will show up in the HTML source! --> 

现在试试这个:

<%# This is a comment that won't show up in the HTML source! %> 
<%# 
    You can even use this for commenting multiple lines! 
    How useful! 
%> 

这有帮助吗?

+0

哇!这样简单的解决方案!谢谢! – AntonAL 2010-08-14 07:52:37

2

使用= begin和= end标记您的评论

+0

这是要走的路。 – 2010-08-08 00:16:13

1

有没有简单的方法来做到这一点的开始和结束。也许,你可以猴子修补ERB的来源,但它有点讨厌。

0

的hackish的种类,但你可以在一个辅助方法

把它包在你看来:

<% comment do %> 
    <%= "this won't be executed" %> 
    or displayed 
<% end %> 

app/helpers/application_helper.rb

module ApplicationHelper 
    def comment(&block) 
    ## you can do something with the block if you want 
    end 
end 
1

也许你可以使用Haml的Comments: -#允许发表评论你的haml代码没有出现在生成的html中。