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 71
        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 67
        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 62
        def add_expr_literal(src, code)
          code.strip!
          src << "(#{@func} #{code})"
        end

add_postamble(src)

[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

add_preamble(src)

[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

add_stmt(src, code)

[Source]

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

add_text(src, text)

[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

escape_text(text)

[Source]

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

escaped_expr(code)

[Source]

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

init_generator(properties={})

[Source]

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

[Validate]