class Temple::Filters::Escapable
@api public
reduce calls to Temple::Utils#escape_html.
It can be enclosed with Temple::Filters::DynamicInliner filters to
This filter must be used after Temple::HTML::* and before the generators.
Escape dynamic or static expressions.
def initialize(opts = {})
def initialize(opts = {}) super @escape_code = options[:escape_code] || "::Temple::Utils.escape_html#{options[:use_html_safe] ? '_safe' : ''}((%s))" @escaper = eval("proc {|v| #{@escape_code % 'v'} }") @escape = false end
def on_dynamic(value)
def on_dynamic(value) [:dynamic, @escape ? @escape_code % value : value] end
def on_escape(flag, exp)
def on_escape(flag, exp) old = @escape @escape = flag && !options[:disable_escape] compile(exp) ensure @escape = old end
def on_static(value)
def on_static(value) [:static, @escape ? @escaper[value] : value] end