Good morning! I am trying to find full documentation about the way to embed ruby commands in the rails views. I am working on a large existing app. We just installed Ruby 1.8.7 on one of our servers in an attempt to get cruisecontrol.rb working with metrics_fu. It seems that this version of ruby does not like comments in the embedded ruby in the rails views. So I am looking through the app, and there are various things in our views, such as: <%= <expression> # comment about <expression> %> <%# comment about stuff around this line %> <%= # commented out code %> <% end # comment about what it is ending %> And the new ruby does not seem to like any of these. It seems as though the %> gets commented out as well. There is also one other thing I could not find documentation for: <%- <some ruby code> -%> Notice the dashes! Do they do anything? Or is it just that you can put dashes and it won''t really affect anything (besides perhaps the return value. Thanks!
On Sep 3, 8:13 pm, nroose <nro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Good morning! > > I am trying to find full documentation about the way to embed ruby > commands in the rails views. > > I am working on a large existing app. We just installed Ruby 1.8.7 on > one of our servers in an attempt to get cruisecontrol.rb working with > metrics_fu. > > It seems that this version of ruby does not like comments in the > embedded ruby in the rails views. > > So I am looking through the app, and there are various things in our > views, such as: > > <%= <expression> # comment about <expression> %> > <%# comment about stuff around this line %> > <%= # commented out code %> > <% end # comment about what it is ending %> >erb in ruby 1.8.7 slightly changed behaviour of what had been previously undefined behaviour (ie it just happened to work before but never documented as such), namely <%# is ok but <% bla bla # and variants thereof aren''t> And the new ruby does not seem to like any of these. It seems as > though the %> gets commented out as well. > > There is also one other thing I could not find documentation for: > > <%- <some ruby code> -%> > > Notice the dashes! Do they do anything? Or is it just that you can > put dashes and it won''t really affect anything (besides perhaps the > return value.it suppresses (usually) spurious blank lines. Fred> > Thanks!
On Thu, Sep 3, 2009 at 12:13 PM, nroose<nroose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Good morning! > > I am trying to find full documentation about the way to embed ruby > commands in the rails views. > > I am working on a large existing app. We just installed Ruby 1.8.7 on > one of our servers in an attempt to get cruisecontrol.rb working with > metrics_fu. > > It seems that this version of ruby does not like comments in the > embedded ruby in the rails views.Correct. Comments in ERB tags only worked by accident -- not a feature.> So I am looking through the app, and there are various things in our > views, such as: > > <%= <expression> # comment about <expression> %> > <%# comment about stuff around this line %> > <%= # commented out code %> > <% end # comment about what it is ending %> > > And the new ruby does not seem to like any of these. It seems as > though the %> gets commented out as well.<%# is the comment tag; it works fine. The others will not.> There is also one other thing I could not find documentation for: > > <%- <some ruby code> -%> > > Notice the dashes! Do they do anything? Or is it just that you can > put dashes and it won''t really affect anything (besides perhaps the > return value.<%- strips leading whitespace -%> strips trailing whitespace, including newline These are useful for precise formatting in plain text emails, for example. Best, jeremy
Thanks! I guess I have some work to do...
This will work: <%= ruby_code # commented_out_code %> You will have to put closing tag ( "%>") in next line. Although this is a hack (and not by design). -- Thanks, Abhinav, http://twitter.com/abhinav On Fri, Sep 4, 2009 at 12:43 AM, nroose <nroose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Good morning! > > I am trying to find full documentation about the way to embed ruby > commands in the rails views. > > I am working on a large existing app. We just installed Ruby 1.8.7 on > one of our servers in an attempt to get cruisecontrol.rb working with > metrics_fu. > > It seems that this version of ruby does not like comments in the > embedded ruby in the rails views. > > So I am looking through the app, and there are various things in our > views, such as: > > <%= <expression> # comment about <expression> %> > <%# comment about stuff around this line %> > <%= # commented out code %> > <% end # comment about what it is ending %> > > And the new ruby does not seem to like any of these. It seems as > though the %> gets commented out as well. > > There is also one other thing I could not find documentation for: > > <%- <some ruby code> -%> > > Notice the dashes! Do they do anything? Or is it just that you can > put dashes and it won''t really affect anything (besides perhaps the > return value. > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/9/4 nroose <nroose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Thanks! > > I guess I have some work to do...You may be able to come with a regexp that you can use for a global search/replace. You possibly want to replace all <%somecode#somecomment%> with <%somecode%><%#somecomment%> though there will no doubt be some special cases. Colin
2009/9/4 Abhinav Saxena <abhinav061-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> This will work: > > <%= ruby_code # commented_out_code > %> > > You will have to put closing tag ( "%>") in next line. Although this is a > hack (and not by design).I don''t think you could rely on that working in all future releases. Colin> > -- > Thanks, > Abhinav, > http://twitter.com/abhinav > > > > On Fri, Sep 4, 2009 at 12:43 AM, nroose <nroose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Good morning! >> >> I am trying to find full documentation about the way to embed ruby >> commands in the rails views. >> >> I am working on a large existing app. We just installed Ruby 1.8.7 on >> one of our servers in an attempt to get cruisecontrol.rb working with >> metrics_fu. >> >> It seems that this version of ruby does not like comments in the >> embedded ruby in the rails views. >> >> So I am looking through the app, and there are various things in our >> views, such as: >> >> <%= <expression> # comment about <expression> %> >> <%# comment about stuff around this line %> >> <%= # commented out code %> >> <% end # comment about what it is ending %> >> >> And the new ruby does not seem to like any of these. It seems as >> though the %> gets commented out as well. >> >> There is also one other thing I could not find documentation for: >> >> <%- <some ruby code> -%> >> >> Notice the dashes! Do they do anything? Or is it just that you can >> put dashes and it won''t really affect anything (besides perhaps the >> return value. >> >> Thanks! >> >> > > > > >