Rendering the partials and templates paths on top of them as HTML comments

20 views
Skip to first unread message

Rafael Magaña

unread,
May 17, 2012, 5:34:11 AM5/17/12
to rubyonra...@googlegroups.com
The idea is to make a little bit easier to find the rendered partials and templates when you start working in an existing project, I know we can see the log but I want something easier, in the log you don't know how the partial looks like only the name. Right now I'm doing this:


 content = layout.render(view, locals){ content } if layout
content.insert(0, "<!-- Partial Rendered: #{@path} -->\n") # <<<<
content

And I get this: 


but I'm looking for a better way to do it, and the main goal is to submit a patch if people think it's worth it or maybe a little gem, don't know, I'd like to have a config option in config/development.rb like this too:
      
          config.action_view.render_template_paths = true

Of course, this is only useful to me in development mode.

Any ideas?

Nick Sutterer

unread,
May 18, 2012, 9:09:07 AM5/18/12
to rubyonra...@googlegroups.com
Hm overriding #render in PartialRenderer looks just right to me.

PartialRenderer.class_eval do
  def render(*)
    super + " Partial rendered.... "
  end
end

Does that work?
Reply all
Reply to author
Forward
0 new messages