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

code generator for Ruby

Methods

Included Modules

Generator StringBufferEnhancer

Public Instance methods

[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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]