# Do you think we should make \<%= # comment %\> not cause error

**URL:** <https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715>\
**Category:** Rails\
**Created:** [May 24, 2009, 10:33pm UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715 "2009-05-24T22:33:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2009, 10:33pm UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/1 "2009-05-24T22:33:11Z")

</div>

the code

\<% # some code %\>

will not cause any error, but the code

\<%= # some code %\>

will cause an error.

the argument is that the second statement is like

output \<\<

and so it is an error.

But I think since

puts “hello”

and

puts

both can run and cause no error, why not make

\<%= # some code %\>

not cause any error too? If we have a language / platform that will  
cause an error when we just comment out code, it is a big issue in the  
long term, since usually when we comment out something, we won’t easily  
cause a problem and may have a hard time finding what the cause is.

for sure, we can change it to

\<% # some code %\>

but we lose the note there that we were going to output the content.  
When we uncomment the code, we don’t know for sure whether it should be  
\<% %\> or \<%= %\> and is prone to mistake again.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2009, 10:35pm UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/2 "2009-05-24T22:35:43Z")

</div>

Report it at [http://rails.uservoice.com](http://rails.uservoice.com), I’d +1 it!

–  
Roderick van Domburg  
[http://www.nedforce.com](http://www.nedforce.com)

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2009, 10:58pm UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/3 "2009-05-24T22:58:22Z")

</div>

In addition I meant to say that according to the ticket link, \<%=# and  
\<%= #  
are also not valid erb comments.  
Colin

2009/5/24 Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2009, 10:44pm UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/4 "2009-05-24T22:44:53Z")

</div>

I believe that \<% #… %\> is not a valid erb comment (no space is  
allowed  
after %). See  
[#1580 Whitespace Bug in Erb Comments in Rails 2.2.2 - Ruby on Rails - rails](https://rails.lighthouseapp.com/projects/8994/tickets/1580-whitespace-bug-in-erb-comments-in-rails-222).  
You have to read through the comments to get to the conclusion.

Colin

2009/5/24 SpringFlowers AutumnMoon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 27, 2009, 7:19am UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/5 "2009-05-27T07:19:01Z")

</div>

Colin L. wrote:

> In addition I meant to say that according to the ticket link, \<%=# and  
> \<%= #  
> are also not valid erb comments.  
> Colin
> 
> 2009/5/24 Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

I Commented code in erb in following ways

\<%# This is Comment %\>

\<%#  
This is Comment  
%\>

\<%#= This is Comment %\>

\<%#=  
This is Comment  
%\>

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 27, 2009, 7:30am UTC](https://www.ruby-forum.com/t/do-you-think-we-should-make-comment-not-cause-error/168715/6 "2009-05-27T07:30:38Z")

</div>

Salil G. wrote:

> I Commented code in erb in following ways
> 
> \<%# This is Comment %\>
> 
> \<%#  
> This is Comment  
> %\>
> 
> \<%#= This is Comment %\>
> 
> \<%#=  
> This is Comment  
> %\>

i see. that’s smart. then we don’t need \<%= #comment %\> to work. but  
if it can, i think it might be good.
