Module: Immunio::FragmentCachingHooks

Extended by:
ActiveSupport::Concern
Defined in:
lib/immunio/plugins/action_view/fragment_caching.rb

Overview

Hook for ‘ActionController::Caching::Fragments` responsible for handling the `<% cache do %>…` in templates.

Instance Method Summary collapse

Instance Method Details

#write_fragment_with_immunio(key, content, options = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/immunio/plugins/action_view/fragment_caching.rb', line 11

def write_fragment_with_immunio(key, content, options = nil)
  return content unless cache_configured?

  template = Template.current
  if template
    # We're rendering a template.
    # Defer caching 'till we get the escaped content from the hook handler.
    content = Template.mark_and_defer_fragment_write(key, content, options)
  else
    # Not rendering a template. Ignore.
    # Shouldn't happen. But, just to be safe in case fragment caching
    # is used in the controller for something else.
    content = write_fragment_without_immunio(key, content, options)
  end

  content
end