Module | Erubis::RubyGenerator
In: | erubis/engine/eruby.rb

code generator for Ruby

### Methods

add_expr_debug add_expr_escaped add_expr_literal add_stmt add_text escape_text escaped_expr init_generator

### Included Modules

Generator StringBufferEnhancer

### Public Instance methods

add_expr_debug(src, code)

[Source]

    # File erubis/engine/eruby.rb, line 63
        def add_expr_debug(src, code)
          code.strip!
          s = (code.dump =~ /\A"(.*)"\z/) && $1
          src << ' $stderr.puts("*** debug: ' << s << '=#{(' << code << ').inspect}");'
        end

add_expr_escaped(src, code)

[Source]

    # File erubis/engine/eruby.rb, line 59
        def add_expr_escaped(src, code)
          src << ' _buf << ' << escaped_expr(code) << ';'
        end

add_expr_literal(src, code)

[Source]

    # File erubis/engine/eruby.rb, line 55
        def add_expr_literal(src, code)
          src << ' _buf << (' << code << ').to_s;'
        end

add_stmt(src, code)

[Source]

    # File erubis/engine/eruby.rb, line 49
        def add_stmt(src, code)
          #src << code << ';'
          src << code
          src << ';' unless code[-1] == ?\n
        end

add_text(src, text)

[Source]

    # File erubis/engine/eruby.rb, line 45
        def add_text(src, text)
          src << " _buf << '" << escape_text(text) << "';" unless text.empty?
        end

escape_text(text)

[Source]

    # File erubis/engine/eruby.rb, line 31
        def escape_text(text)
          text.gsub(/['\\]/, '\\\\\&')   # "'" => "\\'",  '\\' => '\\\\'
        end

escaped_expr(code)

[Source]

    # File erubis/engine/eruby.rb, line 35
        def escaped_expr(code)
          return "#{@escapefunc}(#{code})"
        end

init_generator(properties={})

[Source]

    # File erubis/engine/eruby.rb, line 22
        def init_generator(properties={})
          super
          @escapefunc ||= "Erubis::XmlHelper.escape_xml"
        end

[Validate]