-
Notifications
You must be signed in to change notification settings - Fork 485
Closed
Description
When a component's render? returns false, render_in returns a plain "" instead of "".html_safe.
This is inconsistent with the happy path, which always returns an ActiveSupport::SafeBuffer.
https://github.com/ViewComponent/view_component/blob/main/lib/view_component/base.rb#L163
This is problematic when concatenating a component with something
e.g
render(MyComponent.new) + some_other_method_that_returns_htmlI know i can html_safe explicitly the output of the render call, but would prefer if I didn't have to worry about it.
Steps to reproduce
class MyComponent < ViewComponent::Base
def render? = false
end
result = render(MyComponent.new)Expected behavior
result.html_safe? # => true
result.class # => ActiveSupport::SafeBuffer (or String is fine too as long as it's html_safe)Actual behavior
result.html_safe? # => false
result.class # => StringSystem configuration
Rails version: 8.1.2
Ruby version: 3.3
Gem version: 4.4.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels