Module: Erubis::EscapeEnhancer

Overview

switch ‘<%= … %>’ to escaped and ‘<%== … %>’ to unescaped

ex.

class XmlEruby < Eruby
  include EscapeEnhancer
end

this is language-indenedent.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descObject

:nodoc:



23
24
25
# File 'lib/erubis/enhancer.rb', line 23

def self.desc   # :nodoc:
  "switch '<%= %>' to escaped and '<%== %>' to unescaped"
end

Instance Method Details

#add_expr(src, code, indicator) ⇒ Object

– def self.included(klass)

klass.class_eval <<-END
  alias _add_expr_literal add_expr_literal
  alias _add_expr_escaped add_expr_escaped
  alias add_expr_literal _add_expr_escaped
  alias add_expr_escaped _add_expr_literal
END

end ++



38
39
40
41
42
43
44
45
46
47
# File 'lib/erubis/enhancer.rb', line 38

def add_expr(src, code, indicator)
  case indicator
  when '='
    @escape ? add_expr_literal(src, code) : add_expr_escaped(src, code)
  when '=='
    @escape ? add_expr_escaped(src, code) : add_expr_literal(src, code)
  when '==='
    add_expr_debug(src, code)
  end
end