2010-08-07 78 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中。