If you work with designers or getting to grip with a new codebase you may find yourself frequently answering the question 'What template generates this bit of html'. This smidgen of code adds comments to your html with the path to the templates used. For example the template

Hello
 <%= render :partial => 'some_partial' -%>

might generate

<!-- TEMPLATE: views/dummy/index.html.erb -->
Hello
<!-- TEMPLATE: views/dummy/_some_partial.erb -->
Here is a partial
<!-- ENDTEMPLATE: views/dummy/_some_partial.erb -->
<!-- ENDTEMPLATE: views/dummy/index.html.erb -->

You can grab the code from github. Original idea from this thread on rails-talk

2 Responses to “A Teeny Tiny Plugin for working with others”

  1. Matthew Rudy Jacobs Says:
    Oh wow. I did the same thing a while ago. But I called it "HTML-Trace" and it stopped working after Rails 2.1. Nice though.
  2. Matthew Rudy Jacobs Says:
    also, be wary of anything which may use a; <%=h render :partial => "some_partial" %> as that would obviously break.

Sorry, comments are closed for this article.