Module: Immunio::HamlHooks

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

Overview

Hooks for the HAML template engine.

Instance Method Summary collapse

Instance Method Details

#push_script_with_immunio(code, opts = {}, &block) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/immunio/plugins/action_view.rb', line 472

def push_script_with_immunio(code, opts = {}, &block)
  # Wrap expressions in the templates to track their rendered value.
  Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
    block_expr = if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 0
                   ActionView::Template::Handlers::ERB::Erubi::BLOCK_EXPR
                 else
                   ActionView::Template::Handlers::Erubis::BLOCK_EXPR
                 end

    if code !~ block_expr
      # escape if we're told to by HAML
      code = Immunio::Template.generate_render_var_code(code, opts[:escape_html])
    end
    Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
      push_script_without_immunio(code, opts, &block)
    end
  end
end