Sha256: 7b377d60985f5174e2ba8e2e165a8b3086a6edb34150aba458bfc698d5704195

Contents?: true

Size: 564 Bytes

Versions: 35

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module Filters
    module Compact
      # Removes nil values from an Array
      #
      # Example usage:
      #
      # {{ 'tag,,tag2' | split: ',' | compact }}
      #
      # @param [Array]
      # @return [Array]
      def compact(array)
        return [] unless array.is_a? Array

        @cache = Jekyll::Cache.new('Jekyll::Filters::Compact')

        @cache.getset(array.hash.to_s) do
          array.compact
        end
      end
    end
  end
end

Liquid::Template.register_filter(Jekyll::Filters::Compact)

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
sutty-liquid-0.12.3 lib/jekyll/filters/compact.rb
sutty-liquid-0.12.2 lib/jekyll/filters/compact.rb
sutty-liquid-0.12.1 lib/jekyll/filters/compact.rb
sutty-liquid-0.12.0 lib/jekyll/filters/compact.rb
sutty-liquid-0.12.0rc0 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.12 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.11 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.10 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.9 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.8 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.7 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.6 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.5 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.4 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.3 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.2 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.1 lib/jekyll/filters/compact.rb
sutty-liquid-0.11.0 lib/jekyll/filters/compact.rb
sutty-liquid-0.10.1 lib/jekyll/filters/compact.rb
sutty-liquid-0.10.0 lib/jekyll/filters/compact.rb