Module: Erubis::Generator

Overview

code generator, called by Converter module

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#escapefuncObject

Returns the value of attribute escapefunc.



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

def escapefunc
  @escapefunc
end

Class Method Details

.supported_propertiesObject

:nodoc:



16
17
18
19
20
# File 'lib/erubis/generator.rb', line 16

def self.supported_properties()  # :nodoc:
  return [
          [:escapefunc,    nil,    "escape function name"],
        ]
end

Instance Method Details

#add_expr_debug(src, code) ⇒ Object

(abstract) add expression code to src for debug. this is called by add_expr().



72
73
74
# File 'lib/erubis/generator.rb', line 72

def add_expr_debug(src, code)
  not_implemented
end

#add_expr_escaped(src, code) ⇒ Object

(abstract) add escaped expression code to src. this is called by add_expr().



67
68
69
# File 'lib/erubis/generator.rb', line 67

def add_expr_escaped(src, code)
  not_implemented
end

#add_expr_literal(src, code) ⇒ Object

(abstract) add expression literal code to src. this is called by add_expr().



62
63
64
# File 'lib/erubis/generator.rb', line 62

def add_expr_literal(src, code)
  not_implemented
end

#add_postamble(src) ⇒ Object

(abstract) add @postamble to src



77
78
79
# File 'lib/erubis/generator.rb', line 77

def add_postamble(src)
  not_implemented
end

#add_preamble(src) ⇒ Object

(abstract) add @preamble to src



47
48
49
# File 'lib/erubis/generator.rb', line 47

def add_preamble(src)
  not_implemented
end

#add_stmt(src, code) ⇒ Object

(abstract) add statement code to src



57
58
59
# File 'lib/erubis/generator.rb', line 57

def add_stmt(src, code)
  not_implemented
end

#add_text(src, text) ⇒ Object

(abstract) add text string to src



52
53
54
# File 'lib/erubis/generator.rb', line 52

def add_text(src, text)
  not_implemented
end

#escape_text(text) ⇒ Object

(abstract) escape text string

ex.

def escape_text(text)
  return text.dump
  # or return "'" + text.gsub(/['\\]/, '\\\\\&') + "'"
end


36
37
38
# File 'lib/erubis/generator.rb', line 36

def escape_text(text)
  not_implemented
end

#escaped_expr(code) ⇒ Object

return escaped expression code (ex. ‘h(…)’ or ‘htmlspecialchars(…)’)



41
42
43
44
# File 'lib/erubis/generator.rb', line 41

def escaped_expr(code)
  code.strip!
  return "#{@escapefunc}(#{code})"
end

#init_generator(properties = {}) ⇒ Object



24
25
26
# File 'lib/erubis/generator.rb', line 24

def init_generator(properties={})
  @escapefunc = properties[:escapefunc]
end