Module: Immunio::ErubiHooks

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

Instance Method Summary collapse

Instance Method Details

#add_expression_with_immunio(indicator, code) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/immunio/plugins/action_view/erubi.rb', line 9

def add_expression_with_immunio(indicator, code)
  # Wrap expressions in the templates to track their rendered value.
  # Do not wrap expressions with blocks, eg.: <%= form_tag do %>
  # TODO should we support blocks?
  Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
    unless code =~ ActionView::Template::Handlers::ERB::Erubi::BLOCK_EXPR
      # escape unless we see the == indicator
      escape = !(indicator == '==')
      code = Immunio::Template.generate_render_var_code(code, escape)
    end

    Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
      add_expression_without_immunio(indicator, code)
    end
  end
end