Module: Erubis::RubyGenerator
Overview
Instance Attribute Summary
Attributes included from Generator
#escapefunc
Class Method Summary
collapse
Instance Method Summary
collapse
#add_postamble, #add_preamble, desc
Methods included from Generator
#add_postamble, #add_preamble
Class Method Details
.supported_properties ⇒ Object
27
28
29
|
# File 'lib/erubis/engine/eruby.rb', line 27
def self.supported_properties() return []
end
|
Instance Method Details
#add_expr_debug(src, code) ⇒ Object
63
64
65
66
67
|
# File 'lib/erubis/engine/eruby.rb', line 63
def add_expr_debug(src, code)
code.strip!
s = (code.dump =~ /\A"(.*)"\z/) && $1
src << ' $stderr.puts("*** debug: ' << s << '=#{(' << code << ').inspect}");'
end
|
#add_expr_escaped(src, code) ⇒ Object
59
60
61
|
# File 'lib/erubis/engine/eruby.rb', line 59
def add_expr_escaped(src, code)
src << " #{@bufvar} << " << escaped_expr(code) << ';'
end
|
#add_expr_literal(src, code) ⇒ Object
55
56
57
|
# File 'lib/erubis/engine/eruby.rb', line 55
def add_expr_literal(src, code)
src << " #{@bufvar} << (" << code << ').to_s;'
end
|
#add_stmt(src, code) ⇒ Object
49
50
51
52
53
|
# File 'lib/erubis/engine/eruby.rb', line 49
def add_stmt(src, code)
src << code
src << ';' unless code[-1] == ?\n
end
|
#add_text(src, text) ⇒ Object
– def add_preamble(src)
src << "#{@bufvar} = [];"
end ++
45
46
47
|
# File 'lib/erubis/engine/eruby.rb', line 45
def add_text(src, text)
src << " #{@bufvar} << '" << escape_text(text) << "';" unless text.empty?
end
|
#escape_text(text) ⇒ Object
31
32
33
|
# File 'lib/erubis/engine/eruby.rb', line 31
def escape_text(text)
text.gsub(/['\\]/, '\\\\\&') end
|
#escaped_expr(code) ⇒ Object
35
36
37
|
# File 'lib/erubis/engine/eruby.rb', line 35
def escaped_expr(code)
return "#{@escapefunc}(#{code})"
end
|
#init_generator(properties = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/erubis/engine/eruby.rb', line 21
def init_generator(properties={})
super
@escapefunc ||= "Erubis::XmlHelper.escape_xml"
@bufvar = properties[:bufvar] || "_buf"
end
|