Sha256: d07cba058f08a3f6b3d3b7a7ffb1c0577901eb9f7ac6bfd50d639fa15c1a7687
Contents?: true
Size: 682 Bytes
Versions: 207
Compression:
Stored size: 682 Bytes
Contents
# frozen_string_literal: true # Inspired by https://github.com/JedWatson/classnames # # Helps build a list of conditional class names module Primer # :nodoc: module ClassNameHelper def class_names(*args) [].tap do |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! classes.uniq! end.join(" ") end end end
Version data entries
207 entries across 207 versions & 2 rubygems