Module: Erubis::PerlGenerator
Instance Attribute Summary
Attributes included from Generator
Class Method Summary collapse
-
.supported_properties ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #add_expr_debug(src, code) ⇒ Object
- #add_expr_escaped(src, code) ⇒ Object
- #add_expr_literal(src, code) ⇒ Object
- #add_postamble(src) ⇒ Object
- #add_preamble(src) ⇒ Object
- #add_stmt(src, code) ⇒ Object
- #add_text(src, text) ⇒ Object
- #escape_text(text) ⇒ Object
- #init_generator(properties = {}) ⇒ Object
Methods included from Generator
Class Method Details
.supported_properties ⇒ Object
:nodoc:
16 17 18 19 20 |
# File 'lib/erubis/engine/eperl.rb', line 16 def self.supported_properties() # :nodoc: return [ [:func, 'print', "function name"], ] end |
Instance Method Details
#add_expr_debug(src, code) ⇒ Object
49 50 51 52 53 |
# File 'lib/erubis/engine/eperl.rb', line 49 def add_expr_debug(src, code) code.strip! s = code.gsub(/\'/, "\\'") src << @func << "('*** debug: #{code}=', #{code}, \"\\n\");" end |
#add_expr_escaped(src, code) ⇒ Object
45 46 47 |
# File 'lib/erubis/engine/eperl.rb', line 45 def add_expr_escaped(src, code) add_expr_literal(src, escaped_expr(code)) end |
#add_expr_literal(src, code) ⇒ Object
40 41 42 43 |
# File 'lib/erubis/engine/eperl.rb', line 40 def add_expr_literal(src, code) code.strip! src << @func << "(" << code << "); " end |
#add_postamble(src) ⇒ Object
59 60 61 |
# File 'lib/erubis/engine/eperl.rb', line 59 def add_postamble(src) src << "\n" unless src[-1] == ?\n end |
#add_preamble(src) ⇒ Object
28 29 30 |
# File 'lib/erubis/engine/eperl.rb', line 28 def add_preamble(src) src << "use HTML::Entities; "; end |
#add_stmt(src, code) ⇒ Object
55 56 57 |
# File 'lib/erubis/engine/eperl.rb', line 55 def add_stmt(src, code) src << code end |
#add_text(src, text) ⇒ Object
36 37 38 |
# File 'lib/erubis/engine/eperl.rb', line 36 def add_text(src, text) src << @func << "('" << escape_text(text) << "'); " unless text.empty? end |
#escape_text(text) ⇒ Object
32 33 34 |
# File 'lib/erubis/engine/eperl.rb', line 32 def escape_text(text) return text.gsub!(/['\\]/, '\\\\\&') || text end |
#init_generator(properties = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/erubis/engine/eperl.rb', line 22 def init_generator(properties={}) super @escapefunc ||= 'encode_entities' @func = properties[:func] || 'print' end |