Module: Erubis::SchemeGenerator

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

### Methods

add_expr_debug add_expr_escaped add_expr_literal add_postamble add_preamble add_stmt add_text escape_text escaped_expr init_generator

### Included Modules

Generator

### Public Instance methods

add_expr_debug(src, code)

[Source]

    # File erubis/engine/escheme.rb, line 72
        def add_expr_debug(src, code)
          s = (code.strip! || code).gsub(/\"/, '\\"')
          src << "(display \"*** debug: #{s}=\")(display #{code.strip})(display \"\\n\")"
        end

add_expr_escaped(src, code)

[Source]

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

add_expr_literal(src, code)

[Source]

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

add_postamble(src)

[Source]

    # File erubis/engine/escheme.rb, line 77
        def add_postamble(src)
          return unless @func == '_add'
          src << "\n" unless src[-1] == ?\n
          src << "  (reverse _buf))\n"
        end

add_preamble(src)

[Source]

    # File erubis/engine/escheme.rb, line 29
        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

add_stmt(src, code)

[Source]

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

add_text(src, text)

[Source]

    # File erubis/engine/escheme.rb, line 48
        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

escape_text(text)

[Source]

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

escaped_expr(code)

[Source]

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

init_generator(properties={})

[Source]

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

[Validate]