Class: ActionView::Template::Handlers::Erubis

Inherits:
Erubis::Eruby
  • Object
show all
Defined in:
lib/action_view/template/handlers/erb.rb

Constant Summary collapse

BLOCK_EXPR =
/\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/

Instance Method Summary collapse

Instance Method Details

#add_expr(src, code, indicator) ⇒ Object

Erubis toggles <%= and <%== behavior when escaping is enabled. We override to always treat <%== as escaped.



20
21
22
23
24
25
26
27
# File 'lib/action_view/template/handlers/erb.rb', line 20

def add_expr(src, code, indicator)
  case indicator
  when '=='
    add_expr_escaped(src, code)
  else
    super
  end
end

#add_expr_escaped(src, code) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/action_view/template/handlers/erb.rb', line 39

def add_expr_escaped(src, code)
  if code =~ BLOCK_EXPR
    src << "@output_buffer.safe_append= " << code
  else
    src << "@output_buffer.safe_concat((" << code << ").to_s);"
  end
end

#add_expr_literal(src, code) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/action_view/template/handlers/erb.rb', line 31

def add_expr_literal(src, code)
  if code =~ BLOCK_EXPR
    src << '@output_buffer.append= ' << code
  else
    src << '@output_buffer.append= (' << code << ');'
  end
end

#add_postamble(src) ⇒ Object



47
48
49
# File 'lib/action_view/template/handlers/erb.rb', line 47

def add_postamble(src)
  src << '@output_buffer.to_s'
end

#add_preamble(src) ⇒ Object



9
10
11
# File 'lib/action_view/template/handlers/erb.rb', line 9

def add_preamble(src)
  src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;"
end

#add_text(src, text) ⇒ Object



13
14
15
16
# File 'lib/action_view/template/handlers/erb.rb', line 13

def add_text(src, text)
  return if text.empty?
  src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
end