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.



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

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) ⇒ Object

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



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

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

#on_fescapeObject



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

alias_method :on_fescape, :on_escape