Class: Erubis::Eruby
- Inherits:
-
Object
- Object
- Erubis::Eruby
- Defined in:
- lib/tipsy/handler/erb.rb
Constant Summary collapse
- BLOCK_EXPR =
/\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
Instance Method Summary collapse
- #add_expr_escaped(src, code) ⇒ Object
- #add_expr_literal(src, code) ⇒ Object
- #add_postamble(src) ⇒ Object
- #add_text(src, text) ⇒ Object
Instance Method Details
#add_expr_escaped(src, code) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/tipsy/handler/erb.rb', line 30 def add_expr_escaped(src, code) return if code.nil? if code.to_s =~ BLOCK_EXPR src << "@output_buffer << " << code.to_s else src << "@output_buffer.concat((" << code.to_s << ").to_s);" end end |
#add_expr_literal(src, code) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/tipsy/handler/erb.rb', line 21 def add_expr_literal(src, code) return if code.nil? if code.to_s =~ BLOCK_EXPR src << '@output_buffer << ' << code.to_s else src << '@output_buffer << (' << code.to_s << ');' end end |
#add_postamble(src) ⇒ Object
39 40 41 |
# File 'lib/tipsy/handler/erb.rb', line 39 def add_postamble(src) src << '@output_buffer.to_s' end |
#add_text(src, text) ⇒ Object
14 15 16 17 |
# File 'lib/tipsy/handler/erb.rb', line 14 def add_text(src, text) return if text.empty? || text.nil? src << "@output_buffer.concat('" << escape_text(text) << "');" end |