Template comments?


#1

Is there a way to put comments in templates (not using
HTML)? It appears Ruby only supports single-line
comments (#), and not multiline (/* … */). Right now
I use:

<% if 0==1 %>
comments …
<% end %>

I think I tried ‘if 0’ but it caused an error.

Thanks,
csn


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com


#2

try:

=being
comment
comment
comment
=end

source:
http://hao2lian.f2o.org/wiki/pmwiki.php/Articles/Multi-LineCommentsInRuby

On 11/8/05, CSN removed_email_address@domain.invalid wrote:

I think I tried ‘if 0’ but it caused an error.


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#3

On 11/8/05, CSN removed_email_address@domain.invalid wrote:

Is there a way to put comments in templates (not using
HTML)? It appears Ruby only supports single-line
comments (#), and not multiline (/* … */). Right now
I use:

<% if 0==1 %>
comments …
<% end %>

I think I tried ‘if 0’ but it caused an error.

<%
=begin

commented code here.

=end
%>

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Bill G. (aka aGorilla)


#4

<% if nil %>
comments …
<% end %>

<% if false %>
comments …
<% end %>


#5

On 11/8/05, CSN removed_email_address@domain.invalid wrote:

I use:

if/end (unless the comments are outside of <% …
%>).

odd, as that’s from a template I’ve used recently, and it works fine.

They do have to be on seperate lines because the ‘=’ has to be the 1st
character on the line. This will not work:

<% =begin

commented code here.

=end %>

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Bill G. (aka aGorilla)


#6

— Bill G. removed_email_address@domain.invalid wrote:

comments …
<% end %>

I think I tried ‘if 0’ but it caused an error.

Actually, what happens is the enclosed code still gets
executed. ?

<%
=begin

commented code here.

=end
%>

I tried that, but got errors - Ruby appears to try to
interpret the comments as code. Same goes when using
if/end (unless the comments are outside of <% …
%>).

csn


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com


#7

— Bill G. removed_email_address@domain.invalid wrote:

using

commented code here.

=end %>

Ah, that’s what it was - I had the block indented.

csn


Yahoo! FareChase: Search multiple travel sites in one click.


#8

<%# comment
comment
comment
comment
%>

HTH-
-Ezra

On Nov 8, 2005, at 2:50 PM, CSN wrote:

I use:

if/end (unless the comments are outside of <% …
http://mail.yahoo.com


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732


#9

Sweet. Only problem is if there are additional code
tags in the block, e.g.

<%#
comment
comment
<%= @foo %> <- @foo gets outputted
comment
<% if 1 %> <- this block causes a syntax error
bar
<% end %>
comment
%>

Ah well, guess just use ‘if false/end’ around blocks
like that.

csn

— Ezra Z. removed_email_address@domain.invalid wrote:

now
executed. ?
I tried that, but got errors - Ruby appears to try

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com