Hey, I''ve just switched over to using Erubis for a little speed improvement, however it falls over on any views that call a helper method. This change (google cache cus trac is down): http://216.239.59.104/search?q=cache:H0azguk0XjgJ:dev.rubyonrails.org/changeset/5544+erb_variable&hl=en&ct=clnk&cd=1&gl=uk adds support for changing the erb buffer as required by Erubis which expects _buf instead of _erubis. I don''t know what happened to this change but it certainly isn''t in 1.2.2, anyone know what happened? Cheers ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/7/07, Ian Leitch <port001@gmail.com> wrote:> Hey, > > I''ve just switched over to using Erubis for a little speed improvement, > however it falls over on any views that call a helper method. > > This change (google cache cus trac is down): > http://216.239.59.104/search?q=cache:H0azguk0XjgJ:dev.rubyonrails.org/changeset/5544+erb_variable&hl=en&ct=clnk&cd=1&gl=uk > adds support for changing the erb buffer as required by Erubis which expects > _buf instead of _erubis. I don''t know what happened to this change but it > certainly isn''t in 1.2.2, anyone know what happened? > > Cheers > ianIt didn''t make it the stable branch. If we can get a few real success stories on the use of erubis in Rails, I''ll gladly move it to the stable branch for a 1.2.3 release (assuming there will be one, there are no definite plans). I was working with Ezra on erubis support when I committed that. AFAIK, the erubis rails adapter still needs a few changes to allow it to work with yield, and it should be ready as a drop-in replacement. Er, I see Jeremy committed that. I think we were just working on this at the same time though :) -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks. Apart from yield and the _erbout issue, Erubis has worked just fine, no other issues as far as I can tell (I haven''t tested the CachedRailsTemplate handler yet though). Anything you''d like me to look into? I''d like this to make the next release if possible. Cheers ian On 08/02/07, Rick Olson <technoweenie@gmail.com> wrote:> > > On 2/7/07, Ian Leitch <port001@gmail.com> wrote: > > Hey, > > > > I''ve just switched over to using Erubis for a little speed improvement, > > however it falls over on any views that call a helper method. > > > > This change (google cache cus trac is down): > > > http://216.239.59.104/search?q=cache:H0azguk0XjgJ:dev.rubyonrails.org/changeset/5544+erb_variable&hl=en&ct=clnk&cd=1&gl=uk > > adds support for changing the erb buffer as required by Erubis which > expects > > _buf instead of _erubis. I don''t know what happened to this change but > it > > certainly isn''t in 1.2.2, anyone know what happened? > > > > Cheers > > ian > > It didn''t make it the stable branch. If we can get a few real success > stories on the use of erubis in Rails, I''ll gladly move it to the > stable branch for a 1.2.3 release (assuming there will be one, there > are no definite plans). > > I was working with Ezra on erubis support when I committed that. > AFAIK, the erubis rails adapter still needs a few changes to allow it > to work with yield, and it should be ready as a drop-in replacement. > > Er, I see Jeremy committed that. I think we were just working on this > at the same time though :) > > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t know what the plans for @content_for_layout are, is it going to be removed at some point? If so then this patch is void. My Ruby isn''t great and my knowledge of Rails internals even less so; this patch may indeed suck. This fixes the problem with using yield with some funky nested block magic. I realise this isn''t the Erubis list, though I''d like to get some input on the future of @content_for_layout before standing this upstream. Cheers ian On 08/02/07, Ian Leitch <port001@gmail.com> wrote:> > Thanks. Apart from yield and the _erbout issue, Erubis has worked just > fine, no other issues as far as I can tell (I haven''t tested the > CachedRailsTemplate handler yet though). Anything you''d like me to look > into? I''d like this to make the next release if possible. > > Cheers > ian > > On 08/02/07, Rick Olson <technoweenie@gmail.com> wrote: > > > > > > On 2/7/07, Ian Leitch <port001@gmail.com> wrote: > > > Hey, > > > > > > I''ve just switched over to using Erubis for a little speed > > improvement, > > > however it falls over on any views that call a helper method. > > > > > > This change (google cache cus trac is down): > > > http://216.239.59.104/search?q=cache:H0azguk0XjgJ:dev.rubyonrails.org/changeset/5544+erb_variable&hl=en&ct=clnk&cd=1&gl=uk > > > > > adds support for changing the erb buffer as required by Erubis which > > expects > > > _buf instead of _erubis. I don''t know what happened to this change but > > it > > > certainly isn''t in 1.2.2, anyone know what happened? > > > > > > Cheers > > > ian > > > > It didn''t make it the stable branch. If we can get a few real success > > stories on the use of erubis in Rails, I''ll gladly move it to the > > stable branch for a 1.2.3 release (assuming there will be one, there > > are no definite plans). > > > > I was working with Ezra on erubis support when I committed that. > > AFAIK, the erubis rails adapter still needs a few changes to allow it > > to work with yield, and it should be ready as a drop-in replacement. > > > > Er, I see Jeremy committed that. I think we were just working on this > > at the same time though :) > > > > > > -- > > Rick Olson > > http://weblog.techno-weenie.net > > http://mephistoblog.com > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/8/07, Ian Leitch <port001@gmail.com> wrote:> I don''t know what the plans for @content_for_layout are, is it going to be > removed at some point? If so then this patch is void. My Ruby isn''t great > and my knowledge of Rails internals even less so; this patch may indeed > suck. This fixes the problem with using yield with some funky nested block > magic. I realise this isn''t the Erubis list, though I''d like to get some > input on the future of @content_for_layout before standing this upstream.according to http://www.kuwata-lab.com/erubis/CHANGES, erubis 2.2 should work now. Is it only missing erb_variable or is there more that needs to be done to rails? -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Erubis also has an outstanding patch on the rails helper that [when applied] solves problems with various assigned variables [cookies, etc]. http://rubyforge.org/tracker/index.php?func=detail&aid=6726&group_id=1320&atid=5203 It bites me in the ass every time. But, fortunately, it''s easy enough to fix. It doesn''t look like it''s been resolved into 2.2.0 though. I might be wrong. RSL On 2/12/07, Rick Olson <technoweenie@gmail.com> wrote:> > > On 2/8/07, Ian Leitch <port001@gmail.com> wrote: > > I don''t know what the plans for @content_for_layout are, is it going to > be > > removed at some point? If so then this patch is void. My Ruby isn''t > great > > and my knowledge of Rails internals even less so; this patch may indeed > > suck. This fixes the problem with using yield with some funky nested > block > > magic. I realise this isn''t the Erubis list, though I''d like to get some > > input on the future of @content_for_layout before standing this > upstream. > > according to http://www.kuwata-lab.com/erubis/CHANGES, erubis 2.2 > should work now. Is it only missing erb_variable or is there more > that needs to be done to rails? > > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I can''t get 2.2.0 to work. It looks like it requires a patched action_view/base.rb. It not longer uses the register_template_handler method and instead tries to override the default call to ERB.new, take a look here: http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails rails_helper.rb then as this at the bottom: ## set Erubis as eRuby compiler in Ruby on Rails instead of ERB class ActionView::Base # :nodoc: private def convert_template_into_ruby_code(template) #src = Erubis::Eruby.new(template).src klass = Erubis::Helpers::RailsHelper.engine_class properties = Erubis::Helpers::RailsHelper.init_properties show_src = Erubis::Helpers::RailsHelper.show_src src = klass.new(template, properties).src src.insert(0, ''_erbout = '') logger.debug "** Erubis: src==<<''END''\n#{src}END\n" if show_src src end end There may be a good reason for avoiding register_template_handler like this, though on the face of it it doesn''t look very nice. Also notice the src.insert(0, ''_erbout = '') line, perhaps it''ll work without the erb_variable change. I''m not willing to patch my ActionView base.rb, so I don''t know if yield works now (there is no mention of it in the ChangeLog). Russell, that patch seems to be invalidated by 2.2.0, the code in rails_helper.rb has changed a lot and _localvar_code() no longer exists. On 13/02/07, Russell Norris <sconds@gmail.com> wrote:> > Erubis also has an outstanding patch on the rails helper that [when > applied] solves problems with various assigned variables [cookies, etc]. > > > http://rubyforge.org/tracker/index.php?func=detail&aid=6726&group_id=1320&atid=5203 > > It bites me in the ass every time. But, fortunately, it''s easy enough to > fix. It doesn''t look like it''s been resolved into 2.2.0 though. I might be > wrong. > > RSL > > On 2/12/07, Rick Olson <technoweenie@gmail.com> wrote: > > > > > > On 2/8/07, Ian Leitch <port001@gmail.com> wrote: > > > I don''t know what the plans for @content_for_layout are, is it going > > to be > > > removed at some point? If so then this patch is void. My Ruby isn''t > > great > > > and my knowledge of Rails internals even less so; this patch may > > indeed > > > suck. This fixes the problem with using yield with some funky nested > > block > > > magic. I realise this isn''t the Erubis list, though I''d like to get > > some > > > input on the future of @content_for_layout before standing this > > upstream. > > > > according to http://www.kuwata-lab.com/erubis/CHANGES, erubis 2.2 > > should work now. Is it only missing erb_variable or is there more > > that needs to be done to rails? > > > > > > -- > > Rick Olson > > http://weblog.techno-weenie.net > > http://mephistoblog.com > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
kwa@kuwata-lab.com
2007-Feb-17 11:24 UTC
Re: What happened to ActionView::Base.erb_variable?
Hi Ian, thank you for trying Erubis.> I can''t get 2.2.0 to work. It looks like it requires a patched > action_view/base.rb.It is not necessary to apply the patch. It is optional, because this patch is included in ''erubis/helpers/rails_helper.rb''.> I''m not willing to patch my ActionView base.rb, so I > don''t know if yield works now (there is no mention of it in the ChangeLog).''yield'' will work very well with Erubis 2.2.0. And the following methods which assume that variable name is ''_erbout'' also works. * ActionView::Helpers::CaptureHelper#capture() * ActionView::Helpers::CaptureHelper#content_for() * ActionView::Helpers::TextHelper#concat() If you have any troubles about Erubis 2.2.0 with Ruby on Rails, please tell me. Thank you for trying Erubis. -- regards, kwatch "Ian Leitch" <port...@gmail.com> wrote:> I can''t get 2.2.0 to work. It looks like it requires a patched > action_view/base.rb. It not longer uses the register_template_handler method > and instead tries to override the default call to ERB.new, take a look here:http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails > > rails_helper.rb then as this at the bottom: > > ## set Erubis as eRuby compiler in Ruby on Rails instead of ERB > class ActionView::Base # :nodoc: > private > def convert_template_into_ruby_code(template) > #src = Erubis::Eruby.new(template).src > klass = Erubis::Helpers::RailsHelper.engine_class > properties = Erubis::Helpers::RailsHelper.init_properties > show_src = Erubis::Helpers::RailsHelper.show_src > src = klass.new(template, properties).src > src.insert(0, ''_erbout = '') > logger.debug "** Erubis: src==<<''END''\n#{src}END\n" if show_src > src > end > end > > There may be a good reason for avoiding register_template_handler like this, > though on the face of it it doesn''t look very nice. Also notice the > src.insert(0, ''_erbout = '') line, perhaps it''ll work without the > erb_variable change. I''m not willing to patch my ActionView base.rb, so I > don''t know if yield works now (there is no mention of it in the ChangeLog). > > Russell, that patch seems to be invalidated by 2.2.0, the code in > rails_helper.rb has changed a lot and _localvar_code() no longer exists. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
With just: require ''erubis/helpers/rails_helper'' Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby in my environment.rb it fails because it expects .rhtml extensions on the views. Don''t we need to use register_template_handler at some point to inform rails to look for the .erubis extension too? I don''t see anything in rails_helper.rb that does similar. Could you also explain the reason for avoiding register_template_handler? Cheers ian On 17/02/07, kwa@kuwata-lab.com <kwa@kuwata-lab.com> wrote:> > > Hi Ian, thank you for trying Erubis. > > > I can''t get 2.2.0 to work. It looks like it requires a patched > > action_view/base.rb. > > It is not necessary to apply the patch. It is optional, > because this patch is included in ''erubis/helpers/rails_helper.rb''. > > > I''m not willing to patch my ActionView base.rb, so I > > don''t know if yield works now (there is no mention of it in the > ChangeLog). > > ''yield'' will work very well with Erubis 2.2.0. > And the following methods which assume that variable name is ''_erbout'' > also works. > * ActionView::Helpers::CaptureHelper#capture() > * ActionView::Helpers::CaptureHelper#content_for() > * ActionView::Helpers::TextHelper#concat() > > If you have any troubles about Erubis 2.2.0 with Ruby on Rails, please > tell me. > Thank you for trying Erubis. > > -- > regards, > kwatch > > > "Ian Leitch" <port...@gmail.com> wrote: > > I can''t get 2.2.0 to work. It looks like it requires a patched > > action_view/base.rb. It not longer uses the register_template_handler > method > > and instead tries to override the default call to ERB.new, take a look > here:http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails > > > > rails_helper.rb then as this at the bottom: > > > > ## set Erubis as eRuby compiler in Ruby on Rails instead of ERB > > class ActionView::Base # :nodoc: > > private > > def convert_template_into_ruby_code(template) > > #src = Erubis::Eruby.new(template).src > > klass = Erubis::Helpers::RailsHelper.engine_class > > properties = Erubis::Helpers::RailsHelper.init_properties > > show_src = Erubis::Helpers::RailsHelper.show_src > > src = klass.new(template, properties).src > > src.insert(0, ''_erbout = '') > > logger.debug "** Erubis: src==<<''END''\n#{src}END\n" if show_src > > src > > end > > end > > > > There may be a good reason for avoiding register_template_handler like > this, > > though on the face of it it doesn''t look very nice. Also notice the > > src.insert(0, ''_erbout = '') line, perhaps it''ll work without the > > erb_variable change. I''m not willing to patch my ActionView base.rb, so > I > > don''t know if yield works now (there is no mention of it in the > ChangeLog). > > > > Russell, that patch seems to be invalidated by 2.2.0, the code in > > rails_helper.rb has changed a lot and _localvar_code() no longer exists. > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
kwa@kuwata-lab.com
2007-Feb-17 15:00 UTC
Re: What happened to ActionView::Base.erb_variable?
"Ian Leitch" <port...@gmail.com> wrote:> With just: > require ''erubis/helpers/rails_helper'' > Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby > > in my environment.rb it fails because it expects .rhtml extensions on the > views.what errors do you have? I need details of error messages, with Rails version.> Don''t we need to use register_template_handler at some point to > inform rails to look for the .erubis extension too? I don''t see anything in > rails_helper.rb that does similar. Could you also explain the reason for > avoiding register_template_handler?reasons: * Using register_template_handler() is no merits for Erubis in paticular around performance. ActionView is optimized for ERB and it creates temporary method for view from ''*.rhtml'' file. It works fast because it removes the cost to convert ''*.rhtml'' file into ruby code and parse it. But register_template_handler() reads ''*.rhtml'' file every time and it is necessary to convert eRuby into ruby code and pase it every time. These costs are not small and spoil the merit of Erubis''s speed. You may use Erubis with register_template_handler(), but you will not able to get the advantage of Erubis''s performance. (In fact, ActionView is designed tightly with ERB, I think. There is no way to get template file name in register_template_handler(). It is unconvenient for other template engines except ERB.) * Erubis can convert eRuby file into ruby code correctly. It means that Erubis can replace ERB in Ruby on Rails. I think that there is no problems when replacing ERB with Erubis. If not, please report it to me. -- regards, kwatch --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---