Class: HooplaSalesforce::Eruby

Inherits:
Erubis::Eruby
  • Object
show all
Defined in:
lib/hoopla_salesforce/eruby.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#add_expr_escaped(src, code) ⇒ Object



46
47
48
# File 'lib/hoopla_salesforce/eruby.rb', line 46

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

#add_expr_literal(src, code) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/hoopla_salesforce/eruby.rb', line 30

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



50
51
52
# File 'lib/hoopla_salesforce/eruby.rb', line 50

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

#add_preamble(src) ⇒ Object



19
20
21
# File 'lib/hoopla_salesforce/eruby.rb', line 19

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

#add_stmt(src, code) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/hoopla_salesforce/eruby.rb', line 38

def add_stmt(src, code)
  if code =~ BLOCK_EXPR
    src << code
  else
    super
  end
end

#add_text(src, text) ⇒ Object



23
24
25
26
# File 'lib/hoopla_salesforce/eruby.rb', line 23

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