Module: StyleCapsule::ViewComponent::CallWrapper
- Defined in:
- lib/style_capsule/view_component.rb
Overview
Module that wraps call to add scoped wrapper
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/style_capsule/view_component.rb', line 104 def call if component_styles? # Render styles first styles_html = render_capsule_styles # Get content from original call method content_html = super # Get wrapper tag tag = self.class.wrapper_tag # Wrap content in scoped element scoped_wrapper = helpers.content_tag(tag, content_html.html_safe, data: {capsule: component_capsule}) # Combine styles and wrapped content (styles_html + scoped_wrapper).html_safe else # No styles, render normally super end end |