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:
17 18 19 20 21 |
# File 'lib/erubis/engine/eperl.rb', line 17 def self.supported_properties() # :nodoc: return [ [:func, 'print', "function name"], ] end |
Instance Method Details
#add_expr_debug(src, code) ⇒ Object
50 51 52 53 54 |
# File 'lib/erubis/engine/eperl.rb', line 50 def add_expr_debug(src, code) code.strip! s = code.gsub(/\'/, "\\'") src << @func << "('*** debug: #{code}=', #{code}, \"\\n\");" end |
#add_expr_escaped(src, code) ⇒ Object
46 47 48 |
# File 'lib/erubis/engine/eperl.rb', line 46 def add_expr_escaped(src, code) add_expr_literal(src, escaped_expr(code)) end |
#add_expr_literal(src, code) ⇒ Object
41 42 43 44 |
# File 'lib/erubis/engine/eperl.rb', line 41 def add_expr_literal(src, code) code.strip! src << @func << "(" << code << "); " end |
#add_postamble(src) ⇒ Object
60 61 62 |
# File 'lib/erubis/engine/eperl.rb', line 60 def add_postamble(src) src << "\n" unless src[-1] == ?\n end |
#add_preamble(src) ⇒ Object
29 30 31 |
# File 'lib/erubis/engine/eperl.rb', line 29 def add_preamble(src) src << "use HTML::Entities; "; end |
#add_stmt(src, code) ⇒ Object
56 57 58 |
# File 'lib/erubis/engine/eperl.rb', line 56 def add_stmt(src, code) src << code end |
#add_text(src, text) ⇒ Object
37 38 39 |
# File 'lib/erubis/engine/eperl.rb', line 37 def add_text(src, text) src << @func << "('" << escape_text(text) << "'); " unless text.empty? end |
#escape_text(text) ⇒ Object
33 34 35 |
# File 'lib/erubis/engine/eperl.rb', line 33 def escape_text(text) return text.gsub!(/['\\]/, '\\\\\&') || text end |
#init_generator(properties = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/erubis/engine/eperl.rb', line 23 def init_generator(properties={}) super @escapefunc ||= 'encode_entities' @func = properties[:func] || 'print' end |