Module: Proscenium::CssModule
- Extended by:
- ActiveSupport::Autoload
- Included in:
- Phlex::CssModules, ViewComponent::CssModules
- Defined in:
- lib/proscenium/css_module.rb,
lib/proscenium/css_module/rewriter.rb
Defined Under Namespace
Modules: Path Classes: Name, Rewriter, TransformError, Transformer
Instance Method Summary collapse
-
#class_names(*names, path: nil) ⇒ String
The transformed CSS module names concatenated as a string.
-
#css_module(*names, path: nil) ⇒ String
Accepts one or more CSS class names, and transforms them into CSS module names.
Instance Method Details
#class_names(*names, path: nil) ⇒ String
Returns the transformed CSS module names concatenated as a string.
46 47 48 49 50 |
# File 'lib/proscenium/css_module.rb', line 46 def class_names(*names, path: nil) names = names.flatten.compact transformer = path.nil? ? cssm : Transformer.new(path) transformer.class_names(*names).map { |name, _| name }.join(' ') unless names.empty? end |
#css_module(*names, path: nil) ⇒ String
Accepts one or more CSS class names, and transforms them into CSS module names.
38 39 40 41 |
# File 'lib/proscenium/css_module.rb', line 38 def css_module(*names, path: nil) transformer = path.nil? ? cssm : Transformer.new(path) transformer.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ') end |