Forum: Ruby on Rails template comments?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
cool_screen_name90001 (Guest)
on 2005-11-12 13:49
(Received via mailing list)
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
i8ramin (Guest)
on 2005-11-12 13:49
(Received via mailing list)
try:

=being
comment
comment
comment
=end

source:
http://hao2lian.f2o.org/wiki/pmwiki.php/Articles/M...

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
>



--
- Ramin
http://www.getintothis.com/blog
agorilla (Guest)
on 2005-11-12 13:49
(Received via mailing list)
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)
vanek (Guest)
on 2005-11-12 13:49
(Received via mailing list)
<% if nil %>
  comments .....
<% end %>

<% if false %>
  comments .....
<% end %>
cool_screen_name90001 (Guest)
on 2005-11-12 13:49
(Received via mailing list)
--- 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
agorilla (Guest)
on 2005-11-12 13:49
(Received via mailing list)
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)
cool_screen_name90001 (Guest)
on 2005-11-12 13:49
(Received via mailing list)
--- 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.
http://farechase.yahoo.com
ezra (Guest)
on 2005-11-12 13:49
(Received via mailing list)
<%# 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
cool_screen_name90001 (Guest)
on 2005-11-12 13:49
(Received via mailing list)
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
This topic is locked and can not be replied to.