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_escaped(src, code) ⇒ Object



56
57
58
# File 'lib/action_view/template/handlers/erb.rb', line 56

def add_expr_escaped(src, code)
  src << '@output_buffer.append= ' << escaped_expr(code) << ';'
end

#add_expr_literal(src, code) ⇒ Object



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

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



60
61
62
# File 'lib/action_view/template/handlers/erb.rb', line 60

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

#add_preamble(src) ⇒ Object



29
30
31
# File 'lib/action_view/template/handlers/erb.rb', line 29

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

#add_stmt(src, code) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/action_view/template/handlers/erb.rb', line 48

def add_stmt(src, code)
  if code =~ BLOCK_EXPR
    src << '@output_buffer.append_if_string= ' << code
  else
    super
  end
end

#add_text(src, text) ⇒ Object



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

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