Sha256: 7f287f45d41b76fc972e4255c1f373c0ff13b00b1ed9b440dd0e2eb5172188c8

Contents?: true

Size: 688 Bytes

Versions: 5

Compression:

Stored size: 688 Bytes

Contents

module SlimLint
  module Filters
    # Flattens nested multi expressions while respecting source locatoins.
    #
    # @api public
    class MultiFlattener < Filter
      def on_slim_embedded(*args)
        @self
      end

      def on_multi(*exps)
        # If the multi contains a single element, just return the element
        return compile(exps.first) if exps.size == 1

        result = @self
        result.clear
        result.concat(@key)

        exps.each do |exp|
          exp = compile(exp)
          if exp.first == :multi
            result.concat(exp[1..])
          else
            result << exp
          end
        end

        result
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim_lint_standard-0.0.2.2 lib/slim_lint/filters/multi_flattener.rb
slim_lint_standard-0.0.2.1 lib/slim_lint/filters/multi_flattener.rb
slim_lint_standard-0.0.2 lib/slim_lint/filters/multi_flattener.rb
slim_lint_standard-0.0.1 lib/slim_lint/filters/multi_flattener.rb
slim_lint_standard-0.0.0 lib/slim_lint/filters/multi_flattener.rb