Sha256: 7a0dd3760d3c6eecf6b111c6a6e6f84a392a55a5e6451faf47291500f6742bf3

Contents?: true

Size: 833 Bytes

Versions: 23

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module SlimLint::Filters
  # A dumbed-down version of {Slim::CodeAttributes} which doesn't introduce any
  # temporary variables or other cruft.
  class AttributeProcessor < Slim::Filter
    define_options :merge_attrs

    # Handle attributes expression `[:html, :attrs, *attrs]`
    #
    # @param attrs [Array]
    # @return [Array]
    def on_html_attrs(*attrs)
      [:multi, *attrs.map { |a| compile(a) }]
    end

    # Handle attribute expression `[:html, :attr, name, value]`
    #
    # @param name [String] name of the attribute
    # @param value [Array] Sexp representing the value
    def on_html_attr(name, value)
      if value[0] == :slim && value[1] == :attrvalue
        code = value[3]
        [:code, code]
      else
        @attr = name
        super
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.31.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.30.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.29.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.28.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.27.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.26.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.25.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.24.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.23.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.22.1 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.22.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.21.1 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.21.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.20.2 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.20.1 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.20.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.19.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.18.0 lib/slim_lint/filters/attribute_processor.rb
slim_lint-0.17.1 lib/slim_lint/filters/attribute_processor.rb