Daniel Guettler
2009-Jan-25 22:44 UTC
Question about _pick_template and template_file_extension
Hi, quick question about _pick_template and template_file_extension. The template_file_extension is extracted in the method but not used later to find a template. This leads to the case were a template isn''t found and Template.new(template_path, view_paths) is called which triggers a performance warning. E.g. if you have a template in: app/views/information/scripts.js which you try to include with: render :file => ''information/ scripts.js'' the lookup isn''t checking for "information/scripts.js" in the view_paths if the rendered format for the page is html. Only these cases are checked: self.view_paths["#{template_file_name}.#{template_format}"] and self.view_paths[template_file_name] which both don''t exist. So the question is if there shouldn''t be a case in between like so: if template = self.view_paths["#{template_file_name}.# {template_format}"] template elsif template_file_extension && template = self.view_paths["# {template_file_name}.#{template_file_extension}"] template elsif template = self.view_paths[template_file_name] template Thanks, Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joshua Peek
2009-Jan-26 03:38 UTC
Re: Question about _pick_template and template_file_extension
Ah, so its not picking up templates w/o an extension. Seems like a legit bug. Could you please wrap this up in a patch and create a LH ticket. I think files w/o an extension (in a view path) should be renderable without a template handler. I don''t think they should be erb processed. On Jan 25, 4:44 pm, Daniel Guettler <daniel.guett...@gmail.com> wrote:> Hi, > > quick question about _pick_template and template_file_extension. > The template_file_extension is extracted in the method but not used > later to find a template. This leads to the case were a template isn''t > found and Template.new(template_path, view_paths) is called which > triggers a performance warning. > E.g. if you have a template in: app/views/information/scripts.js > which you try to include with: render :file => ''information/ > scripts.js'' > the lookup isn''t checking for "information/scripts.js" in the > view_paths if the rendered format for the page is html. > Only these cases are checked: > self.view_paths["#{template_file_name}.#{template_format}"] and > self.view_paths[template_file_name] > which both don''t exist. > So the question is if there shouldn''t be a case in between like so: > if template = self.view_paths["#{template_file_name}.# > {template_format}"] > template > elsif template_file_extension && template = self.view_paths["# > {template_file_name}.#{template_file_extension}"] > template > elsif template = self.view_paths[template_file_name] > template > > Thanks, Daniel--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Guettler
2009-Jan-26 16:48 UTC
Re: Question about _pick_template and template_file_extension
I created a ticket at LH: http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1798-render-template-without-templatehandler-extension and attached a patch to it. It applies to 2.2 branch On Jan 25, 10:38 pm, Joshua Peek <j...@joshpeek.com> wrote:> Ah, so its not picking up templates w/o an extension. > > Seems like a legit bug. Could you please wrap this up in a patch and > create a LH ticket. > > I think files w/o an extension (in a view path) should be renderable > without a template handler. I don''t think they should be erb > processed. > > On Jan 25, 4:44 pm, Daniel Guettler <daniel.guett...@gmail.com> wrote: > > > Hi, > > > quick question about _pick_template and template_file_extension. > > The template_file_extension is extracted in the method but not used > > later to find a template. This leads to the case were a template isn''t > > found and Template.new(template_path, view_paths) is called which > > triggers a performance warning. > > E.g. if you have a template in: app/views/information/scripts.js > > which you try to include with: render :file => ''information/ > > scripts.js'' > > the lookup isn''t checking for "information/scripts.js" in the > > view_paths if the rendered format for the page is html. > > Only these cases are checked: > > self.view_paths["#{template_file_name}.#{template_format}"] and > > self.view_paths[template_file_name] > > which both don''t exist. > > So the question is if there shouldn''t be a case in between like so: > > if template = self.view_paths["#{template_file_name}.# > > {template_format}"] > > template > > elsif template_file_extension && template = self.view_paths["# > > {template_file_name}.#{template_file_extension}"] > > template > > elsif template = self.view_paths[template_file_name] > > template > > > Thanks, Daniel--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---