Sha256: 654e9903b527f58889a33953737ded7719f8dc6a0bdb754ea746efe4b257f3c0
Contents?: true
Size: 610 Bytes
Versions: 15
Compression:
Stored size: 610 Bytes
Contents
# frozen_string_literal: true # Inspired by https://github.com/JedWatson/classnames # # Helps build a list of conditional class names module Primer module ClassNameHelper def class_names(*args) classes = [] args.each do |class_name| case class_name when String classes << class_name if class_name.present? when Hash class_name.each do |key, val| classes << key if val end when Array classes << class_names(*class_name).presence end end classes.compact.uniq.join(" ") end end end
Version data entries
15 entries across 15 versions & 1 rubygems