Class: Haml::ForceEscapable

Inherits:
Escapable
  • Object
show all
Defined in:
lib/haml/force_escapable.rb

Overview

Unlike Haml::Escapable, this escapes value even if it’s html_safe.

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ForceEscapable

Returns a new instance of ForceEscapable.



16
17
18
19
20
# File 'lib/haml/force_escapable.rb', line 16

def initialize(opts = {})
  super
  @escape_code = options[:escape_code] || "::Haml::Util.escape_html((%s))"
  @escaper = eval("proc {|v| #{@escape_code % 'v'} }")
end

Instance Method Details

#on_escape(flag, exp)

ForceEscapable doesn’t touch :escape expression. This method is not used if it’s inserted after Haml::Escapable.



26
27
28
# File 'lib/haml/force_escapable.rb', line 26

def on_escape(flag, exp)
  [:escape, flag, compile(exp)]
end

#on_fescape



22
# File 'lib/haml/force_escapable.rb', line 22

alias_method :on_fescape, :on_escape