mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Oct-12 08:29 UTC
Easy Way to identify Partials
Hey there, here we have a bunch of interns, so called marketing specialists and other folks just pushing out more and more layouts, views and partials. Now when theres a SEO wanting to change a link on page A to point to landing page 123 isntead of landing page 234 it can be a pain to jsut find the file where this link is generated. Do you know of an easy way to identify which part of a page comes from which partial file? Perhaps a plugin adding a border or something? Greeting Mike --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your log file lists all of the partials that are rendered to build up a page - is that enough information? mine looks like this for example. Rendered ratings/_rate (258.6ms) Rendered resources/_single_resource (268.7ms) Rendered resources/_resource (276.7ms) Rendered resources/_property_hyperlinks (1.6ms) Rendered resources/_note_tag_list (0.8ms) Rendered taggings/_tags_section (1.4ms) listing those has highlighted the fact that some of them are very slow, must go and see if i can optimise them... -- Posted via http://www.ruby-forum.com/.
Thanks for your. I was already aware of the log file. It is OK, but it would be fine if i had some hints in the rendered HTML. Something like <!-- =BEGIN layouts/application.html.erb --> <head><title>Flux Compensator</title></head> <body> <!-- =BEGIN layouts/products.html.erb --> <h1>Showing you a Product</h1> <!-- =BEGIN products/show.html.erb --> Product Name: <b>Flux Compensator</b> Parts: <!-- =BEGIN product/_part.html.erb --> Hypercapacitor Gizmo<br/> <!-- =END products/_part.html.erb --> <p>Thank you for your interest in Flux Compensator</p> <!-- =END products/show.html.erb --> <a href="/products">Index</a> <!-- =END layouts/products.html.erb --> </body> <!-- =END layouts/application.html.erb --> It would be lovely if there was a plugin that accomplishes this. I would also appreciate any hint as to how achieve this functionality. Thanks, Mike On Mon, Oct 12, 2009 at 3:08 PM, Max Williams < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Your log file lists all of the partials that are rendered to build up a > page - is that enough information? mine looks like this for example. > > Rendered ratings/_rate (258.6ms) > Rendered resources/_single_resource (268.7ms) > Rendered resources/_resource (276.7ms) > Rendered resources/_property_hyperlinks (1.6ms) > Rendered resources/_note_tag_list (0.8ms) > Rendered taggings/_tags_section (1.4ms) > > listing those has highlighted the fact that some of them are very slow, > must go and see if i can optimise them... > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
On Mon, Oct 12, 2009 at 3:29 AM, <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Do you know of an easy way to identify which part of a page comes from which > partial file? Perhaps a plugin adding a border or something?This will add comments to your erb templates: unless RAILS_ENV == ''production'' module ActionView module TemplateHandlers class ERB < TemplateHandler include Compilable cattr_accessor :erb_trim_mode self.erb_trim_mode = ''-'' def compile(template) src = ::ERB.new("<% __in_erb_template=true %>\n<!-- BEGIN #{ template } -->\n#{ template.source}\n<!-- END #{ template } -->\n", nil, erb_trim_mode, ''@output_buffer'').src RUBY_VERSION >= ''1.9'' ? src.sub(/\A#coding:.*\n/, '''') : src end end end end end Mine lives in my environment.rb. -- Greg Donald http://destiney.com/
Greg Donald wrote:> On Mon, Oct 12, 2009 at 3:29 AM, <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Do you know of an easy way to identify which part of a page comes from which >> partial file? Perhaps a plugin adding a border or something? > > This will add comments to your erb templates: >[...] Ooh, neat! I''ll have to play with that -- thanks for sharing it. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Yay, thank you Greg! On Wed, Oct 14, 2009 at 12:06 AM, Marnen Laibow-Koser < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Greg Donald wrote: > > On Mon, Oct 12, 2009 at 3:29 AM, <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Do you know of an easy way to identify which part of a page comes from > which > >> partial file? Perhaps a plugin adding a border or something? > > > > This will add comments to your erb templates: > > > [...] > > Ooh, neat! I''ll have to play with that -- thanks for sharing it. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
On Oct 13, 9:16 pm, mike <mikez...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It would be lovely if there was a plugin that accomplishes this. I would > also appreciate any hint as to how achieve this functionality. >I wrote this a little while ago: http://github.com/fcheung/tattler Fred> Thanks, Mike > > On Mon, Oct 12, 2009 at 3:08 PM, Max Williams < > > > > rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > Your log file lists all of the partials that are rendered to build up a > > page - is that enough information? mine looks like this for example. > > > Rendered ratings/_rate (258.6ms) > > Rendered resources/_single_resource (268.7ms) > > Rendered resources/_resource (276.7ms) > > Rendered resources/_property_hyperlinks (1.6ms) > > Rendered resources/_note_tag_list (0.8ms) > > Rendered taggings/_tags_section (1.4ms) > > > listing those has highlighted the fact that some of them are very slow, > > must go and see if i can optimise them... > > -- > > Posted viahttp://www.ruby-forum.com/.
Greg, your solution works great. However, it can interfere with js templates. So i added <% if request and request.xhr? %> to the injected code. Frederick, will look into it when im in the office :) Greetings 2009/10/13, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > On Mon, Oct 12, 2009 at 3:29 AM, <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Do you know of an easy way to identify which part of a page comes from >> which >> partial file? Perhaps a plugin adding a border or something? > > This will add comments to your erb templates: > > unless RAILS_ENV == ''production'' > module ActionView > module TemplateHandlers > class ERB < TemplateHandler > include Compilable > cattr_accessor :erb_trim_mode > self.erb_trim_mode = ''-'' > def compile(template) > src = ::ERB.new("<% __in_erb_template=true %>\n<!-- BEGIN #{ > template } -->\n#{ template.source}\n<!-- END #{ template } -->\n", > nil, erb_trim_mode, ''@output_buffer'').src > RUBY_VERSION >= ''1.9'' ? src.sub(/\A#coding:.*\n/, '''') : src > end > end > end > end > end > > Mine lives in my environment.rb. > > > -- > Greg Donald > http://destiney.com/ > > > >-- Von meinen Mobilgerät aus gesendet
Nice Plugin! On Fri, Oct 16, 2009 at 12:20 PM, mike <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Greg, your solution works great. However, it can interfere with js > templates. So i added <% if request and request.xhr? %> to the > injected code. > Frederick, will look into it when im in the office :) > Greetings > > 2009/10/13, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > On Mon, Oct 12, 2009 at 3:29 AM, <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Do you know of an easy way to identify which part of a page comes from > >> which > >> partial file? Perhaps a plugin adding a border or something? > > > > This will add comments to your erb templates: > > > > unless RAILS_ENV == ''production'' > > module ActionView > > module TemplateHandlers > > class ERB < TemplateHandler > > include Compilable > > cattr_accessor :erb_trim_mode > > self.erb_trim_mode = ''-'' > > def compile(template) > > src = ::ERB.new("<% __in_erb_template=true %>\n<!-- BEGIN #{ > > template } -->\n#{ template.source}\n<!-- END #{ template } -->\n", > > nil, erb_trim_mode, ''@output_buffer'').src > > RUBY_VERSION >= ''1.9'' ? src.sub(/\A#coding:.*\n/, '''') : src > > end > > end > > end > > end > > end > > > > Mine lives in my environment.rb. > > > > > > -- > > Greg Donald > > http://destiney.com/ > > > > > > > > > > -- > Von meinen Mobilgerät aus gesendet >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---