Module | Erubis::RubyGenerator |
In: |
erubis/engine/eruby.rb
|
code generator for Ruby
# File erubis/engine/eruby.rb, line 63 def add_expr_debug(src, code) code.strip! s = (code.dump =~ /\A"(.*)"\z/) && $1 src << ' $stderr.puts("*** debug: ' << s << '=#{(' << code << ').inspect}");' end
# File erubis/engine/eruby.rb, line 59 def add_expr_escaped(src, code) src << ' _buf << ' << escaped_expr(code) << ';' end
# File erubis/engine/eruby.rb, line 55 def add_expr_literal(src, code) src << ' _buf << (' << code << ').to_s;' end
# File erubis/engine/eruby.rb, line 49 def add_stmt(src, code) #src << code << ';' src << code src << ';' unless code[-1] == ?\n end
# File erubis/engine/eruby.rb, line 45 def add_text(src, text) src << " _buf << '" << escape_text(text) << "';" unless text.empty? end
# File erubis/engine/eruby.rb, line 31 def escape_text(text) text.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\' end