Sha256: eb4cbe48b0a96e1d9cd6665b14dbb6496dcb71a68ef855d8d8450fec31d2d8e5

Contents?: true

Size: 476 Bytes

Versions: 2

Compression:

Stored size: 476 Bytes

Contents

# frozen_string_literal: true

module BridgetownSvgInliner
  class LiquidAttributes
    attr_reader :path, :args

    def initialize(attributes)
      path, args = attributes.split(",", 2)

      @path = unescape_string(path)
      @args = args.scan(Liquid::TagAttributes).map do |arg|
        [arg[0], unescape_string(arg[1])]
      end.to_h if args.present?
    end

    private

    def unescape_string(string)
      string.undump
    rescue
      string
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bridgetown-svg-inliner-1.0.1 lib/bridgetown-svg-inliner/liquid_attributes.rb
bridgetown-svg-inliner-1.0.0 lib/bridgetown-svg-inliner/liquid_attributes.rb