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:



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

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 ++



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

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