Module Erubis::SchemeGenerator
In: erubis/engine/escheme.rb

Methods

Included Modules

Generator

Public Instance methods

[Source]

# 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

[Source]

# File erubis/engine/escheme.rb, line 67
    def add_expr_escaped(src, code)
      add_expr_literal(src, escaped_expr(code))
    end

[Source]

# File erubis/engine/escheme.rb, line 62
    def add_expr_literal(src, code)
      code.strip!
      src << "(#{@func} #{code})"
    end

[Source]

# 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

[Source]

# 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

[Source]

# File erubis/engine/escheme.rb, line 58
    def add_stmt(src, code)
      src << code
    end

[Source]

# 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

[Source]

# File erubis/engine/escheme.rb, line 36
    def escape_text(text)
      @table_ ||= { '"'=>'\\"', '\\'=>'\\\\' }
      text.gsub!(/["\\]/) { |m| @table_[m] }
      return text
    end

[Source]

# File erubis/engine/escheme.rb, line 42
    def escaped_expr(code)
      code.strip!
      return "(#{@escapefunc} #{code})"
    end

[Source]

# File erubis/engine/escheme.rb, line 22
    def init_generator(properties={})
      super
      @escapefunc ||= 'escape'
      @func = properties[:func] || '_add'   # or 'display'
    end

[Validate]