Module: Erubis::Generator
- Included in:
- Basic::Engine, CGenerator, JavaGenerator, JavascriptGenerator, OptimizedGenerator, PI::Engine, PerlGenerator, PhpGenerator, RubyGenerator, SchemeGenerator
- Defined in:
- lib/erubis/generator.rb
Overview
code generator, called by Converter module
Instance Attribute Summary collapse
-
#escapefunc ⇒ Object
Returns the value of attribute escapefunc.
Class Method Summary collapse
-
.supported_properties ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#add_expr_debug(src, code) ⇒ Object
(abstract) add expression code to src for debug.
-
#add_expr_escaped(src, code) ⇒ Object
(abstract) add escaped expression code to src.
-
#add_expr_literal(src, code) ⇒ Object
(abstract) add expression literal code to src.
-
#add_postamble(src) ⇒ Object
(abstract) add @postamble to src.
-
#add_preamble(src) ⇒ Object
(abstract) add @preamble to src.
-
#add_stmt(src, code) ⇒ Object
(abstract) add statement code to src.
-
#add_text(src, text) ⇒ Object
(abstract) add text string to src.
-
#escape_text(text) ⇒ Object
(abstract) escape text string.
-
#escaped_expr(code) ⇒ Object
return escaped expression code (ex. ‘h(…)’ or ‘htmlspecialchars(…)’).
- #init_generator(properties = {}) ⇒ Object
Instance Attribute Details
#escapefunc ⇒ Object
Returns the value of attribute escapefunc.
23 24 25 |
# File 'lib/erubis/generator.rb', line 23 def escapefunc @escapefunc end |
Class Method Details
.supported_properties ⇒ Object
:nodoc:
17 18 19 20 21 |
# File 'lib/erubis/generator.rb', line 17 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().
73 74 75 |
# File 'lib/erubis/generator.rb', line 73 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().
68 69 70 |
# File 'lib/erubis/generator.rb', line 68 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().
63 64 65 |
# File 'lib/erubis/generator.rb', line 63 def add_expr_literal(src, code) not_implemented end |
#add_postamble(src) ⇒ Object
(abstract) add @postamble to src
78 79 80 |
# File 'lib/erubis/generator.rb', line 78 def add_postamble(src) not_implemented end |
#add_preamble(src) ⇒ Object
(abstract) add @preamble to src
48 49 50 |
# File 'lib/erubis/generator.rb', line 48 def add_preamble(src) not_implemented end |
#add_stmt(src, code) ⇒ Object
(abstract) add statement code to src
58 59 60 |
# File 'lib/erubis/generator.rb', line 58 def add_stmt(src, code) not_implemented end |
#add_text(src, text) ⇒ Object
(abstract) add text string to src
53 54 55 |
# File 'lib/erubis/generator.rb', line 53 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
37 38 39 |
# File 'lib/erubis/generator.rb', line 37 def escape_text(text) not_implemented end |
#escaped_expr(code) ⇒ Object
return escaped expression code (ex. ‘h(…)’ or ‘htmlspecialchars(…)’)
42 43 44 45 |
# File 'lib/erubis/generator.rb', line 42 def escaped_expr(code) code.strip! return "#{@escapefunc}(#{code})" end |
#init_generator(properties = {}) ⇒ Object
25 26 27 |
# File 'lib/erubis/generator.rb', line 25 def init_generator(properties={}) @escapefunc = properties[:escapefunc] end |