Module | Erubis::RubyGenerator |
In: |
erubis/engine/eruby.rb
|
code generator for Ruby
# File erubis/engine/eruby.rb, line 62 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 58 def add_expr_escaped(src, code) src << ' _buf << ' << escaped_expr(code) << ';' end
# File erubis/engine/eruby.rb, line 54 def add_expr_literal(src, code) src << ' _buf << (' << code << ').to_s;' end
# File erubis/engine/eruby.rb, line 48 def add_stmt(src, code) #src << code << ';' src << code src << ';' unless code[-1] == ?\n end
# File erubis/engine/eruby.rb, line 44 def add_text(src, text) src << " _buf << '" << escape_text(text) << "';" unless text.empty? end
# File erubis/engine/eruby.rb, line 30 def escape_text(text) text.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\' end