Sha256: 8bd0b73fdbbd46b5df489cd0d3624c7042e961a420111378fa1f9704ccef1f50

Contents?: true

Size: 992 Bytes

Versions: 252

Compression:

Stored size: 992 Bytes

Contents

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

require 'cgi'


module Erubis


  ##
  ## for preprocessing
  ##
  class PreprocessingEruby < Erubis::Eruby

    def initialize(input, params={})
      params = params.dup
      params[:pattern] ||= '\[% %\]'    # use '[%= %]' instead of '<%= %>'
      #params[:escape] = true            # transport '[%= %]' and '[%== %]'
      super
    end

    def add_expr_escaped(src, code)
      add_expr_literal(src, "_decode((#{code}))")
    end

  end


  ##
  ## helper methods for preprocessing
  ##
  module PreprocessingHelper

    module_function

    def _p(arg)
      return "<%=#{arg}%>"
    end

    def _P(arg)
      return "<%=h(#{arg})%>"
    end

    alias _? _p

    def _decode(arg)
      arg = arg.to_s
      arg.gsub!(/%3C%25(?:=|%3D)(.*?)%25%3E/) { "<%=#{CGI.unescape($1)}%>" }
      arg.gsub!(/&lt;%=(.*?)%&gt;/) { "<%=#{CGI.unescapeHTML($1)}%>" }
      return arg
    end

  end


end

Version data entries

252 entries across 212 versions & 42 rubygems

Version Path
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
brakeman-4.6.1 bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
brakeman-4.6.0 bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
brakeman-4.5.1 bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
brakeman-4.5.0 bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
brakeman-4.4.0 bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb