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 62
    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 58
    def add_expr_escaped(src, code)
      src << ' _buf << ' << escaped_expr(code) << ';'
    end

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]