Module: Immunio::HamlHooks
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/immunio/plugins/action_view/haml.rb
Overview
Hooks for the HAML template engine.
Instance Method Summary collapse
Instance Method Details
#push_script_with_immunio(code, opts = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/immunio/plugins/action_view/haml.rb', line 10 def push_script_with_immunio(code, opts = {}, &block) # 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 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 |