Class Erubis::Eperl
In: erubis/engine/eperl.rb
Parent: Engine

engine for Perl

Methods

Public Class methods

[Source]

# File erubis/engine/eperl.rb, line 25
    def initialize(input, properties={})
      @func = properties[:func] || 'print'
      super
    end

Public Instance methods

[Source]

# File erubis/engine/eperl.rb, line 55
    def add_expr_debug(src, code)
      code.strip!
      s = code.gsub(/\'/, "\\'")
      src << @func << "('*** debug: #{code}=', #{code}, \"\\n\");"
    end

[Source]

# File erubis/engine/eperl.rb, line 51
    def add_expr_escaped(src, code)
      src << @func << "(" << escaped_expr(code) << "); "
    end

[Source]

# File erubis/engine/eperl.rb, line 47
    def add_expr_literal(src, code)
      src << @func << "(" << code.strip << "); "
    end

[Source]

# File erubis/engine/eperl.rb, line 65
    def add_postamble(src)
      src << "\n" unless src[-1] == ?\n
    end

[Source]

# File erubis/engine/eperl.rb, line 30
    def add_preamble(src)
      # empty
    end

[Source]

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

[Source]

# File erubis/engine/eperl.rb, line 38
    def add_text(src, text)
      src << @func << "('" << escape_text(text) << "'); " unless text.empty?
    end

[Source]

# File erubis/engine/eperl.rb, line 34
    def escape_text(text)
      return text.gsub!(/['\\]/, '\\\\\&') || text
    end

[Source]

# File erubis/engine/eperl.rb, line 42
    def escaped_expr(code)
      @escape ||= 'escape'
      return "escape(#{code.strip})"
    end

[Validate]