Sha256: ff30668815643b592c281f3a6b4a018cafae5678e726476463c92cfea0b5c682
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module Proscenium::CssModule extend ActiveSupport::Autoload autoload :Path autoload :Transformer class TransformError < StandardError def initialize(name, additional_msg = nil) msg = "Failed to transform CSS module `#{name}`" msg << ' - ' << additional_msg if additional_msg super msg end end # Accepts one or more CSS class names, and transforms them into CSS module names. # # @param name [String,Symbol,Array<String,Symbol>] # @return [String] the transformed CSS module names concatenated as a string. def css_module(*names) cssm.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ') end # @param name [String,Symbol,Array<String,Symbol>] # @return [String] the transformed CSS module names concatenated as a string. def class_names(*names) names = names.flatten.compact cssm.class_names(*names).map { |name, _| name }.join(' ') unless names.empty? end private def cssm @cssm ||= Transformer.new(self.class.css_module_path) end end
Version data entries
4 entries across 4 versions & 1 rubygems