Space Vatican

Ramblings of a curious coder

A Teeny Tiny Plugin for Working With Others

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

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

might generate

1
2
3
4
5
6
<!-- 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