Created
May 9, 2014 20:34
-
-
Save bmaddy/4567fad5aa55e5a600e1 to your computer and use it in GitHub Desktop.
An initializer to show what parts of your page come from what rails partials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start the app with EXPLAIN_PARTIALS=true to show locations of view partials | |
if Rails.env.development? and ENV['EXPLAIN_PARTIALS'] | |
module ActionView | |
class PartialRenderer | |
def render_with_explanation(*args) | |
rendered = render_without_explanation(*args).to_s | |
# Note: We haven't figured out how to get a path when @template is nil. | |
start_explanation = "\n<!-- START PARTIAL #{@template.inspect} -->\n" | |
end_explanation = "\n<!-- END PARTIAL #{@template.inspect} -->\n" | |
start_explanation.html_safe + rendered + end_explanation.html_safe | |
end | |
alias_method_chain :render, :explanation | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment