Module | Erubis::SchemeGenerator |
In: |
erubis/engine/escheme.rb
|
# File erubis/engine/escheme.rb, line 71 def add_expr_debug(src, code) s = (code.strip! || code).gsub(/\"/, '\\"') src << "(display \"*** debug: #{s}=\")(display #{code.strip})(display \"\\n\")" end
# File erubis/engine/escheme.rb, line 67 def add_expr_escaped(src, code) add_expr_literal(src, escaped_expr(code)) end
# File erubis/engine/escheme.rb, line 62 def add_expr_literal(src, code) code.strip! src << "(#{@func} #{code})" end
# File erubis/engine/escheme.rb, line 76 def add_postamble(src) return unless @func == '_add' src << "\n" unless src[-1] == ?\n src << " (reverse _buf))\n" end
# File erubis/engine/escheme.rb, line 28 def add_preamble(src) return unless @func == '_add' src << "(let ((_buf '())) " + \ "(define (_add x) (set! _buf (cons x _buf))) " #src << "(let* ((_buf '())" + # " (_add (lambda (x) (set! _buf (cons x _buf))))) " end
# File erubis/engine/escheme.rb, line 47 def add_text(src, text) return if text.empty? t = escape_text(text) if t[-1] == ?\n t[-1, 1] = '' src << "(#{@func} \"" << t << "\\n\")\n" else src << "(#{@func} \"" << t << '")' end end
# File erubis/engine/escheme.rb, line 36 def escape_text(text) @table_ ||= { '"'=>'\\"', '\\'=>'\\\\' } text.gsub!(/["\\]/) { |m| @table_[m] } return text end
# File erubis/engine/escheme.rb, line 42 def escaped_expr(code) code.strip! return "(#{@escapefunc} #{code})" end