Tuesday, September 23, 2008

Rails hack: Adding html comments to label partials

Ever want to figure out which partial a block of html is coming from without greping through your entire rails project? Render_partial_comments is a rails plugin that renders html comments to mark the begin and end of partial output. Give it a try:
ruby script/plugin install git://github.com/avvo/render_partial_comments.git
Then enable it by adding this global in config/environments/development.rb (or wherever)
$render_partial_comments = true
Then restart your server... Your rendered html will now include html comments wrapping the output from partials. Should look something like this:
<!-- render_begin 'user/view' -->
....
<!-- render_end 'user/view' -->
Update: This may have some adverse effects on autocomplete if you use it

No comments: