Module: Immunio::ErubisHooks

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

Overview

Hooks for the ERB template engine. (Default one used in Rails < 5.1).

Instance Method Summary collapse

Instance Method Details

#add_expr_with_immunio(src, code, indicator) ⇒ Object



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

def add_expr_with_immunio(src, code, indicator)
  # 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::Erubis::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_expr_without_immunio(src, code, indicator)
    end
  end
end