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
try: =being comment comment comment =end source: http://hao2lian.f2o.org/wiki/pmwiki.php/Articles/Multi-LineCommentsInRuby On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> 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. > > Thanks, > csn > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors'' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Ramin http://www.getintothis.com/blog _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> 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 %>> Thanks, > csn > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors'' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Bill Guindon (aka aGorilla)
<% if nil %> comments ..... <% end %> <% if false %> comments ..... <% end %> CSN 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. > > Thanks, > csn
--- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > 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.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
On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > --- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > > 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. > > 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 <% ... > %>).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 %>> csn > > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors'' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Bill Guindon (aka aGorilla)
--- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > wrote: > > > > --- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On 11/8/05, CSN > <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > > > 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. > > > > 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 <% ... > > %>). > > 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 %>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:> > --- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> >> 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. > > 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 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 Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote:> <%# comment > comment > comment > comment > %> > > HTH- > -Ezra > > On Nov 8, 2005, at 2:50 PM, CSN wrote: > > > > > --- Bill Guindon <agorilla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> On 11/8/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > >> 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. > > > > 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 > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Mail - PC Magazine Editors'' Choice 2005 http://mail.yahoo.com