Sha256: 3cac6ed883372d9027be0370c48910cfcead5f71027f0d5574314fe07a90e856

Contents?: true

Size: 1.36 KB

Versions: 102

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true
require 'nokogiri/xslt/stylesheet'

module Nokogiri
  class << self
    ###
    # Create a Nokogiri::XSLT::Stylesheet with +stylesheet+.
    #
    # Example:
    #
    #   xslt = Nokogiri::XSLT(File.read(ARGV[0]))
    #
    def XSLT stylesheet, modules = {}
      XSLT.parse(stylesheet, modules)
    end
  end

  ###
  # See Nokogiri::XSLT::Stylesheet for creating and manipulating
  # Stylesheet object.
  module XSLT
    class << self
      ###
      # Parse the stylesheet in +string+, register any +modules+
      def parse string, modules = {}
        modules.each do |url, klass|
          XSLT.register url, klass
        end

        if Nokogiri.jruby?
          Stylesheet.parse_stylesheet_doc(XML.parse(string), string)
        else
          Stylesheet.parse_stylesheet_doc(XML.parse(string))
        end
      end

      ###
      # Quote parameters in +params+ for stylesheet safety
      def quote_params params
        parray = (params.instance_of?(Hash) ? params.to_a.flatten : params).dup
        parray.each_with_index do |v,i|
          if i % 2 > 0
            parray[i]=
              if v =~ /'/
                "concat('#{ v.gsub(/'/, %q{', "'", '}) }')"
              else
                "'#{v}'";
              end
          else
            parray[i] = v.to_s
          end
        end
        parray.flatten
      end
    end
  end
end

Version data entries

102 entries across 97 versions & 4 rubygems

Version Path
nokogiri-backport-1.11.0 lib/nokogiri/xslt.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xslt.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xslt.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.11.7-x86_64-linux/lib/nokogiri/xslt.rb
nokogiri-1.11.7 lib/nokogiri/xslt.rb
nokogiri-1.11.7-x86_64-linux lib/nokogiri/xslt.rb
nokogiri-1.11.7-x86_64-darwin lib/nokogiri/xslt.rb
nokogiri-1.11.7-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.11.7-x86-linux lib/nokogiri/xslt.rb
nokogiri-1.11.7-x64-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.11.7-java lib/nokogiri/xslt.rb
nokogiri-1.11.7-arm64-darwin lib/nokogiri/xslt.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.3-x86_64-linux/lib/nokogiri/xslt.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xslt.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xslt.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xslt.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xslt.rb
nokogiri-1.11.6 lib/nokogiri/xslt.rb
nokogiri-1.11.6-x86_64-linux lib/nokogiri/xslt.rb
nokogiri-1.11.6-x86_64-darwin lib/nokogiri/xslt.rb