Class: ViewComponentContrib::Preview::Base
- Inherits:
-
ViewComponent::Preview
- Object
- ViewComponent::Preview
- ViewComponentContrib::Preview::Base
- Includes:
- DefaultTemplate
- Defined in:
- lib/view_component_contrib/preview/base.rb
Overview
Base view component class with extensions already included
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_CONTAINER_CLASS =
""
Constants included from DefaultTemplate
DefaultTemplate::DEFAULT_TEMPLATE
Class Attribute Summary collapse
Class Method Summary collapse
-
.inherited(child) ⇒ Object
Support layout inheritance.
- .render_args ⇒ Object
Instance Method Summary collapse
-
#render_component(component) ⇒ Object
Shortcut for render_with_template(locals: …).
-
#render_with(**locals) ⇒ Object
Shortcut for render_with_template(locals: …).
Methods included from DefaultTemplate
Class Attribute Details
.container_class ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/view_component_contrib/preview/base.rb', line 27 def container_class return @container_class if defined?(@container_class) @container_class = if superclass.respond_to?(:container_class) superclass.container_class else DEFAULT_CONTAINER_CLASS end end |
Class Method Details
.inherited(child) ⇒ Object
Support layout inheritance
20 21 22 23 |
# File 'lib/view_component_contrib/preview/base.rb', line 20 def inherited(child) child.layout(@layout) if defined?(@layout) super end |
.render_args ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/view_component_contrib/preview/base.rb', line 38 def render_args(...) super.tap do |res| res[:locals] ||= {} build_component_instance(res[:locals]) res[:locals][:container_class] ||= container_class end end |
Instance Method Details
#render_component(component) ⇒ Object
Shortcut for render_with_template(locals: …)
63 64 65 |
# File 'lib/view_component_contrib/preview/base.rb', line 63 def render_component(component) render_with(component: component) end |
#render_with(**locals) ⇒ Object
Shortcut for render_with_template(locals: …)
58 59 60 |
# File 'lib/view_component_contrib/preview/base.rb', line 58 def render_with(**locals) render_with_template(locals: locals) end |