Class: ViewComponentScopedCss::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component_scoped_css/tag.rb

Overview

style tag for outputting inline css

Instance Method Summary collapse

Constructor Details

#initialize(component_class) ⇒ Tag

Returns a new instance of Tag.



8
9
10
# File 'lib/view_component_scoped_css/tag.rb', line 8

def initialize(component_class)
  @component_class = component_class
end

Instance Method Details

#callObject



12
13
14
# File 'lib/view_component_scoped_css/tag.rb', line 12

def call
  "<style data-component-name=\"#{@component_class.name}\">#{css}</style>".html_safe
end

#cssObject



16
17
18
# File 'lib/view_component_scoped_css/tag.rb', line 16

def css
  ViewComponentScopedCss::Loader.new(@component_class).call.html_safe
end