Class: Hamlit::ForceEscapable

Inherits:
Escapable show all
Defined in:
lib/hamlit/force_escapable.rb

Overview

Unlike Hamlit::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/hamlit/force_escapable.rb', line 15

def initialize(opts = {})
  super
  @escape_code = options[:escape_code] || "::Hamlit::Utils.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 Hamlit::Escapable.



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

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

#on_fescapeObject



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

alias_method :on_fescape, :on_escape