Class: ViewComponent::Collection
- Inherits:
-
Object
- Object
- ViewComponent::Collection
- Includes:
- ActionView::Helpers::OutputSafetyHelper, Enumerable
- Defined in:
- lib/view_component/collection.rb
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#format ⇒ Object
Rails expects us to define ‘format` on all renderables, but we do not know the `format` of a ViewComponent until runtime.
- #render_in(view_context, **_, &block) ⇒ Object
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
11 12 13 |
# File 'lib/view_component/collection.rb', line 11 def component @component end |
Instance Method Details
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/view_component/collection.rb', line 22 def each(&block) components.each(&block) end |
#format ⇒ Object
Rails expects us to define ‘format` on all renderables, but we do not know the `format` of a ViewComponent until runtime.
29 30 31 |
# File 'lib/view_component/collection.rb', line 29 def format nil end |
#render_in(view_context, **_, &block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/view_component/collection.rb', line 15 def render_in(view_context, **_, &block) rendered = components.map do |component| component.render_in(view_context, &block) end safe_join(rendered, rendered_spacer(view_context)) end |