Template comments?

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

try:

=being
comment
comment
comment
=end

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

On 11/8/05, CSN [email protected] wrote:

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


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

On 11/8/05, CSN [email protected] 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Bill G. (aka aGorilla)

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

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

On 11/8/05, CSN [email protected] 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Bill G. (aka aGorilla)

— Bill G. [email protected] 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

— Bill G. [email protected] 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.
http://farechase.yahoo.com

<%# 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
[email protected]
509-577-7732

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. [email protected] wrote:

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

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
[email protected]
509-577-7732


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Yahoo! Mail - PC Magazine Editors’ Choice 2005