module Nokogiri::XSLT
def quote_params(params)
[Returns] Array of string parameters, with quotes correctly escaped for use with XSLT::Stylesheet.transform
- +params+ (Hash, Array) XSLT parameters (key->value, or tuples of [key, value])
[Parameters]
See Nokogiri::XSLT::Stylesheet.transform for example usage.
Quote parameters in +params+ for stylesheet safety.
quote_params(params) → Array
:call-seq:
def quote_params(params) params.flatten.each_slice(2).with_object([]) do |kv, quoted_params| key, value = kv.map(&:to_s) value = if value.include?("'") "concat('#{value.gsub("'", %q{', "'", '})}')" else "'#{value}'" end quoted_params << key quoted_params << value end end