Module | Erubis::JavaGenerator |
In: |
erubis/engine/ejava.rb
|
# File erubis/engine/ejava.rb, line 69 def add_expr_debug(src, code) code.strip! src << @indent if src.empty? || src[-1] == ?\n src << " System.err.println(\"*** debug: #{code}=\"+(#{code}));" end
# File erubis/engine/ejava.rb, line 65 def add_expr_escaped(src, code) add_expr_literal(src, escaped_expr(code)) end
# File erubis/engine/ejava.rb, line 59 def add_expr_literal(src, code) src << @indent if src.empty? || src[-1] == ?\n code.strip! src << " #{@buf}.append(#{code});" end
# File erubis/engine/ejava.rb, line 75 def add_postamble(src) src << "\n" if src[-1] == ?; src << @indent << "return " << @buf << ".toString();\n" #src << @indent << "System.out.print(" << @buf << ".toString());\n" end
# File erubis/engine/ejava.rb, line 33 def add_preamble(src) src << "#{@indent}#{@bufclass} #{@buf} = new #{@bufclass}();" end
# File erubis/engine/ejava.rb, line 42 def add_text(src, text) return if text.empty? src << (src.empty? || src[-1] == ?\n ? @indent : ' ') src << @buf << ".append(" i = 0 text.each_line do |line| src << "\n" << @indent << ' + ' if i > 0 i += 1 src << '"' << escape_text(line) << '"' end src << ");" << (text[-1] == ?\n ? "\n" : "") end
# File erubis/engine/ejava.rb, line 37 def escape_text(text) @@table_ ||= { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" } return text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] } || text end