# Views: comments for template and partial location in filesystem?

**URL:** <https://www.ruby-forum.com/t/views-comments-for-template-and-partial-location-in-filesystem/194246>\
**Category:** Rails\
**Created:** [September 1, 2010, 3:29pm UTC](https://www.ruby-forum.com/t/views-comments-for-template-and-partial-location-in-filesystem/194246 "2010-09-01T15:29:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 1, 2010, 3:29pm UTC](https://www.ruby-forum.com/t/views-comments-for-template-and-partial-location-in-filesystem/194246/1 "2010-09-01T15:29:44Z")

</div>

I’m looking for an extension (gem, plugin, whatever) that inserts  
comments like

... around rendered templates (except in production env). A cursory search didn't bring up anything, but I may have chosen the wrong terms. It doesn't have to work for arbitrary template engines, ERB is enough. Michael -- Michael S. mailto:removed\_email\_address@domain.invalid http://www.schuerig.de/michael/

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 1, 2010, 3:44pm UTC](https://www.ruby-forum.com/t/views-comments-for-template-and-partial-location-in-filesystem/194246/2 "2010-09-01T15:44:11Z")

</div>

Michael S. wrote:

> I’m looking for an extension (gem, plugin, whatever) that inserts  
> comments like

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 2, 2010, 12:47am UTC](https://www.ruby-forum.com/t/views-comments-for-template-and-partial-location-in-filesystem/194246/3 "2010-09-02T00:47:46Z")

</div>

On Wednesday 01 September 2010, Marnen Laibow-Koser wrote:

> > terms. It doesn’t have to work for arbitrary template engines, ERB  
> > is enough.
> 
> You want Frederick C.'s Tattler:  
> [GitHub - fcheung/tattler](http://github.com/fcheung/tattler) . I think it will work with any  
> template engine; certainly I’m using it with Haml. I don’t know if  
> it works with Rails 3 yet.

Tattler doesn’t work with Rails 3 anymore. This little bit of code,  
inspired by it, does.

unless Rails.env.production?  
class ActionView::Template  
def render\_with\_comment(\*args, &block)  
render\_result = render\_without\_comment(\*args, &block)  
if mime\_type.nil? || mime\_type === [Mime::HTML, Mime::XML]  
(“\n” +  
render\_result +  
“\n”  
).html\_safe  
else  
render\_result  
end  
end  
alias\_method\_chain :render, :comment  
end  
end

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
