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

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...

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

Flux Compensator

Showing you a Product

Product Name: Flux Compensator

Parts:

Hypercapacitor Gizmo

Thank you for your interest in Flux Compensator

Index

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

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.

Yay, thank you Greg!

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

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 :slight_smile:
Greetings

Nice Plugin!