# Easy Way to identify Partials

**URL:** <https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134>\
**Category:** Rails\
**Created:** [October 12, 2009, 10:31am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134 "2009-10-12T10:31:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 12, 2009, 10:31am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/1 "2009-10-12T10:31:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 12, 2009, 3:08pm UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/2 "2009-10-12T15:08:37Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 13, 2009, 10:18pm UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/3 "2009-10-13T22:18:36Z")

</div>

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](https://www.ruby-forum.com/products)

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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 14, 2009, 12:06am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/4 "2009-10-14T00:06:02Z")

</div>

Greg D. wrote:

> On Mon, Oct 12, 2009 at 3:29 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 14, 2009, 10:56am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/5 "2009-10-14T10:56:10Z")

</div>

Yay, thank you Greg!

On Wed, Oct 14, 2009 at 12:06 AM, Marnen Laibow-Koser \<

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 14, 2009, 12:01am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/6 "2009-10-14T00:01:39Z")

</div>

On Mon, Oct 12, 2009 at 3:29 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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\n#{ template.source}\n\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 D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 14, 2009, 11:37am UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/7 "2009-10-14T11:37:44Z")

</div>

On Oct 13, 9:16 pm, mike [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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: [GitHub - fcheung/tattler](http://github.com/fcheung/tattler)

Fred

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 16, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/8 "2009-10-16T17:02:50Z")

</div>

Nice Plugin!

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 16, 2009, 12:21pm UTC](https://www.ruby-forum.com/t/easy-way-to-identify-partials/177134/9 "2009-10-16T12:21:51Z")

</div>

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 D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> module TemplateHandlers
> end
> 
> ```
> 
> >

–  
Von meinen Mobilgerät aus gesendet
