Class: PartialLogging::PartialRendererWithLogging

Inherits:
ActionView::PartialRenderer
  • Object
show all
Defined in:
lib/partial_logging/partial_renderer_with_logging.rb

Instance Method Summary collapse

Instance Method Details

#formatted_partial_identifier(identifier) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/partial_logging/partial_renderer_with_logging.rb', line 21

def formatted_partial_identifier(identifier)
  if PartialLogging.config.absolute_path?
    identifier
  else
    identifier.sub(/#{Rails.root.to_s}/, '(app root)')
  end
end

#render(context, options, block) ⇒ ActionView::OutputBuffer

Returns:

  • (ActionView::OutputBuffer)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/partial_logging/partial_renderer_with_logging.rb', line 6

def render(context, options, block)
  content = super(context, options, block)
  identifier = @template ? @template.identifier : @path
  if @lookup_context.rendered_format == :html
    output_buffer = ActionView::OutputBuffer.new
    output_buffer.safe_concat """
    <!-- START #{formatted_partial_identifier(identifier)} -->
      #{content}
    <!-- END #{formatted_partial_identifier(identifier)} -->
    """
    content = output_buffer
  end
  content
end