Class: StyleComponent
- Defined in:
- app/components/style_component.rb
Overview
Style — inline <style> tag.
Usage:
Style(".my-class { color: red; }")
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
-
#initialize(css = nil, **kwargs) ⇒ StyleComponent
constructor
A new instance of StyleComponent.
- #render_in(context, &block) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(css = nil, **kwargs) ⇒ StyleComponent
Returns a new instance of StyleComponent.
9 10 11 12 |
# File 'app/components/style_component.rb', line 9 def initialize(css = nil, **kwargs) @css = css super(**kwargs) end |
Instance Method Details
#render_in(context, &block) ⇒ Object
14 15 16 17 18 |
# File 'app/components/style_component.rb', line 14 def render_in(context, &block) @view_context = context @css ||= context.capture(&block) if block to_s end |
#to_s ⇒ Object
20 21 22 |
# File 'app/components/style_component.rb', line 20 def to_s tag.style { @css&.html_safe } end |