Hello, I have the following: <% @projects.each do |project| %> <tr> . <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', :method => :delete %></td> . </tr> <% end %> How can I safely comment out the TD line above? Do I have to use the =begin way? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-Sep-18 17:34 UTC
Re: Commenting in an ERB without generating a compiling error
> <% @projects.each do |project| %> > <tr> > . > <td><%= link_to ''Destroy'', project, :confirm => ''Are you > sure?'', :method => :delete %></td> > . > </tr> > <% end %> > > > How can I safely comment out the TD line above? Do I have to use the > =begin way?If you don''t mind HTML comments, just wrap it in <!-- ..... -> If you just want the link gone, but keep the <td> you can make the start tag look like <%#= and it should work (if memory serves). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
nobosh
2010-Sep-18 17:50 UTC
Re: Commenting in an ERB without generating a compiling error
Thanks for the reply. I need to avoid HTML comments. Also, I tried <%= <td><%= link_to ''Destroy'', project, :confirm => ''Are you > sure?'', :method => :delete %></td> %> And what happens is every time it runs through the loop it outputs on the page: </td> %>, meaning the " %> from the TD is being used to close the comment, which is why I''m trying to find out a way to comment this line out Thanks On Sep 18, 10:34 am, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > <% @projects.each do |project| %> > > <tr> > > . > > <td><%= link_to ''Destroy'', project, :confirm => ''Are you > > sure?'', :method => :delete %></td> > > . > > </tr> > > <% end %> > > > How can I safely comment out the TD line above? Do I have to use the > > =begin way? > > If you don''t mind HTML comments, just wrap it in <!-- ..... -> > > If you just want the link gone, but keep the <td> you can make the start tag look like <%#= and it should work (if memory serves).-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2010-Sep-18 17:54 UTC
Re: Re: Commenting in an ERB without generating a compiling error
because the parser see this <%#= <td><%= link_to ''Destroy'', project, :confirm => ''Are you > sure?'', :method => :delete %> and thinks i ended there so it thinks </td> %> is text put a <%#= in front of the </td> %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-Sep-18 17:57 UTC
Re: Re: Commenting in an ERB without generating a compiling error
On Sep 18, 2010, at 10:50 AM, nobosh wrote:> Thanks for the reply. I need to avoid HTML comments. Also, I tried > > <%= <td><%= link_to ''Destroy'', project, :confirm => ''Are you > > sure?'', :method => :delete %></td> %> > > And what happens is every time it runs through the loop it outputs on > the page: </td> %>, meaning the " %> from the TD is being used to > close the comment, which is why I''m trying to find out a way to > comment this line outThis is evil, but it will work... <%%q{ <td><%= link_to ''Destroy'', project, :confirm => ''Are you > sure?'', :method => :delete %></td> }%> The %q{...} turns everything within it into an un-evaluated string. And the <% without the <%= results in no output. If you don''t even want the blank line change the last %> to -%> -philip> Thanks > > On Sep 18, 10:34 am, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: >>> <% @projects.each do |project| %> >>> <tr> >>> . >>> <td><%= link_to ''Destroy'', project, :confirm => ''Are you >>> sure?'', :method => :delete %></td> >>> . >>> </tr> >>> <% end %> >> >>> How can I safely comment out the TD line above? Do I have to use the >>> =begin way? >> >> If you don''t mind HTML comments, just wrap it in <!-- ..... -> >> >> If you just want the link gone, but keep the <td> you can make the start tag look like <%#= and it should work (if memory serves). > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
nobosh
2010-Sep-18 19:35 UTC
Re: Commenting in an ERB without generating a compiling error
Thanks all, just a little surprised that Rails doesn''t have a simpilar way to comment things out in the view. On Sep 18, 10:57 am, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> On Sep 18, 2010, at 10:50 AM, nobosh wrote: > > > Thanks for the reply. I need to avoid HTML comments. Also, I tried > > > <%= <td><%= link_to ''Destroy'', project, :confirm => ''Are you > > > sure?'', :method => :delete %></td> %> > > > And what happens is every time it runs through the loop it outputs on > > the page: </td> %>, meaning the " %> from the TD is being used to > > close the comment, which is why I''m trying to find out a way to > > comment this line out > > This is evil, but it will work... > > <%%q{ <td><%= link_to ''Destroy'', project, :confirm => ''Are you > > sure?'', :method => :delete %></td> }%> > > The %q{...} turns everything within it into an un-evaluated string. And the <% without the <%= results in no output. If you don''t even want the blank line change the last %> to -%> > > -philip > > > > > Thanks > > > On Sep 18, 10:34 am, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: > >>> <% @projects.each do |project| %> > >>> <tr> > >>> . > >>> <td><%= link_to ''Destroy'', project, :confirm => ''Are you > >>> sure?'', :method => :delete %></td> > >>> . > >>> </tr> > >>> <% end %> > > >>> How can I safely comment out the TD line above? Do I have to use the > >>> =begin way? > > >> If you don''t mind HTML comments, just wrap it in <!-- ..... -> > > >> If you just want the link gone, but keep the <td> you can make the start tag look like <%#= and it should work (if memory serves). > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Sep-18 21:05 UTC
Re: Commenting in an ERB without generating a compiling error
nobosh wrote:> Thanks all, just a little surprised that RailsYou mean ERb.> doesn''t have a simpilar > way to comment things out in the view.Sure it does: <%# comment %> You should probably be using Haml instead of ERb, though. Best, -- -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2010-Sep-19 08:29 UTC
Re: Re: Commenting in an ERB without generating a compiling error
On 18 September 2010 22:05, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> nobosh wrote: >> doesn''t have a simpilar >> way to comment things out in the view. > > Sure it does: > <%# comment %>That won''t help him comment his <td> though...> You should probably be using Haml instead of ERb, though.Why? What failure is the OP experiencing that HAML would make succeed? (BTW, I like HAML, but it''s this sort of exclamation of yours without any supporting citations that seems to rile people - try rephrasing along the lines of "check out HAML for a more succinct and easier to read way of rendering your views rather than using the bundled Erb"... or something). If there''s a method in HAML that would allow him to comment his <td> without a lot of fussing, show that too, since that''s the problem he''s facing. Back to the OP: I use a fairly straightforward way of removing code from execution, in the view, model, controller, and in whatever language I happen to be using - wrap it in a conditional check that doesn''t return true: <% if false %> <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', :method => :delete %></td> <% end %> Similarly, if you *never* want an existing conditional statement to pass, use: <% if false && <your original condition here> %> and if you *always* want it to pass: <% if true || <your original condition here> %> ...easy to add and easy to remove. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Sep-19 16:37 UTC
Re: Re: Commenting in an ERB without generating a compiling error
Michael Pavling wrote:> On 18 September 2010 22:05, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> nobosh wrote: >>> doesn''t have a simpilar >>> way to comment things out in the view. >> >> Sure it does: >> <%# comment %> > > That won''t help him comment his <td> though...Of course it will. He can just put the whole <td> construct in an ERb comment tag. ERb doesn''t pay attention to HTML nesting. Or am I misunderstanding what you''re saying? Or is this an issue of multiline comments in ERb? I font think it is, but if so, then =begin or if false may be necessary.> >> You should probably be using Haml instead of ERb, though. > > Why? What failure is the OP experiencing that HAML would make succeed?Haml does have a nicer comment syntax, but I suggested it because it''s generally more pleasant to work with than ERb, not due to a "failure".> (BTW, I like HAML, but it''s this sort of exclamation of yours without > any supporting citations that seems to rile people - try rephrasing > along the lines of "check out HAML for a more succinct and easier to > read way of rendering your views rather than using the bundled Erb"... > or something).I and others have probably said that a hundred times in this list by now. That''s why we have archives... Also, I didn''t want to hijack the thread.> If there''s a method in HAML that would allow him to > comment his <td> without a lot of fussing, show that too, since that''s > the problem he''s facing.Now that would *really* be hijacking the thread.> > > Back to the OP: > > I use a fairly straightforward way of removing code from execution, in > the view, model, controller, and in whatever language I happen to be > using - wrap it in a conditional check that doesn''t return true: > > <% if false %> > <td><%= link_to ''Destroy'', project, :confirm => ''Are you > sure?'', :method => :delete %></td> > <% end %>Yes, that''s a very useful trick.> > Similarly, if you *never* want an existing conditional statement to > pass, use: > <% if false && <your original condition here> %> > > and if you *always* want it to pass: > <% if true || <your original condition here> %> > > ...easy to add and easy to remove.Cool! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2010-Sep-19 18:16 UTC
Re: Re: Re: Commenting in an ERB without generating a compiling error
On 19 September 2010 17:37, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Michael Pavling wrote: >> That won''t help him comment his <td> though... > > Of course it will. He can just put the whole <td> construct in an ERb > comment tag. ERb doesn''t pay attention to HTML nesting. Or am I > misunderstanding what you''re saying?The original line was: <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', :method => :delete %></td> so If I changed that to : <%# <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', :method => :delete %></td> %> I would be squawked at by the parser, or rather, just get an extraneous "</td> %>" in my HTML, because the comment would be closed by the first "%>" Which is why I just tend to cut the the chase, and put an "if false" around the lot. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2010-Sep-19 18:19 UTC
Re: Re: Re: Commenting in an ERB without generating a compiling error
@Michael Pavling wow thats a good one -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Sep-19 19:07 UTC
Re: Re: Re: Commenting in an ERB without generating a compiling error
Michael Pavling wrote:> On 19 September 2010 17:37, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> Michael Pavling wrote: >>> That won''t help him comment his <td> though... >> >> Of course it will. �He can just put the whole <td> construct in an ERb >> comment tag. �ERb doesn''t pay attention to HTML nesting. �Or am I >> misunderstanding what you''re saying? > > The original line was: > <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', > :method => :delete %></td> > > so If I changed that to : > > <%# <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', > :method => :delete %></td> %> > > I would be squawked at by the parser, or rather, just get an > extraneous "</td> %>" in my HTML, because the comment would be closed > by the first "%>" > > Which is why I just tend to cut the the chase, and put an "if false" > around the lot.Ah, yes. Hadn''t thought about the extra %>. Duh. I should have read more carefully; sorry. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.