Sha256: 382dedc05dd597d94bffd68eb8f37989bb498daf60199737eef65b794b02bf40

Contents?: true

Size: 643 Bytes

Versions: 27

Compression:

Stored size: 643 Bytes

Contents

module Lookbook
  module ClassNamesHelper
    def build_tag_values(*args)
      tag_values = []

      args.each do |tag_value|
        case tag_value
        when Hash
          tag_value.each do |key, val|
            tag_values << key.to_s if val && key.present?
          end
        when Array
          tag_values.concat build_tag_values(*tag_value)
        else
          tag_values << tag_value.to_s if tag_value.present?
        end
      end

      tag_values
    end

    def class_names(*args)
      tokens = build_tag_values(*args).flat_map { |value| value.to_s.split(/\s+/) }.uniq

      safe_join(tokens, " ")
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
lookbook-2.3.4 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.3.3 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.3.2 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.3.0 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.2.2 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.2.1 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.2.0 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.1.1 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.5 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.4 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.3 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.2 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.1 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.rc.3 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.rc.2 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.rc.1 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.beta.9 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.beta.8 lib/lookbook/helpers/class_names_helper.rb
lookbook-2.0.0.beta.7 lib/lookbook/helpers/class_names_helper.rb