module RailsTemplateDebugger::ActionViewTemplateRenderWithComment

Public Instance Methods

render(view, locals, buffer = nil, &block) click to toggle source
Calls superclass method
# File lib/rails_template_debugger.rb, line 9
def render(view, locals, buffer = nil, &block)
  return super unless html_template?

  path = identifier.remove(Rails.root.to_s + "/")
  # path_short = path.match(/app\/views\/(.*)/)&.captures&.first

  [
    "<!-- TEMPLATE START #{path} -->",
    "<meta name='rails_template_debugger' path='#{path}' />",
    super,
    "<!-- TEMPLATE END #{path} -->"
  ].join("\n").html_safe
end

Private Instance Methods

html_template?() click to toggle source
# File lib/rails_template_debugger.rb, line 25
def html_template?
  identifier =~ /\.html(?:\.\w+)?$/ && !(identifier =~ /\/layouts\//)
end