Sha256: f3d9e0a63e287804a0d36c40c4f8b82130fae808447ad2a2649b88cc11c01d61

Contents?: true

Size: 1.55 KB

Versions: 252

Compression:

Stored size: 1.55 KB

Contents

##
## $Release: 2.7.0 $
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
##

require 'erubis/engine'
require 'erubis/enhancer'


module Erubis


  module PhpGenerator
    include Generator

    def self.supported_properties()  # :nodoc:
      return []
    end

    def init_generator(properties={})
      super
      @escapefunc ||= 'htmlspecialchars'
    end

    def add_preamble(src)
      # empty
    end

    def escape_text(text)
      return text.gsub!(/<\?xml\b/, '<<?php ?>?xml') || text
    end

    def add_text(src, text)
      src << escape_text(text)
    end

    def add_expr_literal(src, code)
      code.strip!
      src << "<?php echo #{code}; ?>"
    end

    def add_expr_escaped(src, code)
      add_expr_literal(src, escaped_expr(code))
    end

    def add_expr_debug(src, code)
      code.strip!
      s = code.gsub(/\'/, "\\'")
      src << "<?php error_log('*** debug: #{s}='.(#{code}), 0); ?>"
    end

    def add_stmt(src, code)
      src << "<?php"
      src << " " if code[0] != ?\ #
      if code[-1] == ?\n
        code.chomp!
        src << code << "?>\n"
      else
        src << code << "?>"
      end
    end

    def add_postamble(src)
      # empty
    end

  end


  ##
  ## engine for PHP
  ##
  class Ephp < Basic::Engine
    include PhpGenerator
  end


  class EscapedEphp < Ephp
    include EscapeEnhancer
  end


  #class XmlEphp < Ephp
  #  include EscapeEnhancer
  #end


  class PI::Ephp < PI::Engine
    include PhpGenerator

    def init_converter(properties={})
      @pi = 'php'
      super(properties)
    end

  end


end

Version data entries

252 entries across 212 versions & 42 rubygems

Version Path
brakeman-4.0.0 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb