Class: Haml::Escapable
- Inherits:
-
Temple::Filter
- Object
- Temple::Filter
- Haml::Escapable
- Defined in:
- lib/haml/escapable.rb
Overview
Like Temple::Filters::Escapable, but with support for escaping by Haml::Herlpers.html_escape and Haml::Herlpers.escape_once.
Instance Method Summary collapse
-
#initialize ⇒ Escapable
constructor
A new instance of Escapable.
-
#on_dynamic(value)
The same as Haml::AttributeBuilder.build_attributes.
-
#on_escape(flag, exp)
-
#on_static(value)
The same as Haml::AttributeBuilder.build_attributes.
Constructor Details
#initialize ⇒ Escapable
Returns a new instance of Escapable
7 8 9 10 11 12 13 14 |
# File 'lib/haml/escapable.rb', line 7
def initialize(*)
super
@escape_code = "::Haml::Helpers.html_escape((%s))"
@escaper = eval("proc {|v| #{@escape_code % 'v'} }")
@once_escape_code = "::Haml::Helpers.escape_once((%s))"
@once_escaper = eval("proc {|v| #{@once_escape_code % 'v'} }")
@escape = false
end
|
Instance Method Details
#on_dynamic(value)
The same as Haml::AttributeBuilder.build_attributes
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/haml/escapable.rb', line 38
def on_dynamic(value)
[:dynamic,
if @escape == :once
@once_escape_code % value
elsif @escape
@escape_code % value
else
"(#{value}).to_s"
end
]
end
|