Skip to content

Fix render_in returning non-html_safe string when render? is false#2584

Merged
joelhawksley merged 4 commits intomainfrom
copilot/fix-render-in-html-safe-output
Mar 25, 2026
Merged

Fix render_in returning non-html_safe string when render? is false#2584
joelhawksley merged 4 commits intomainfrom
copilot/fix-render-in-html-safe-output

Conversation

Copy link
Contributor

Copilot AI commented Mar 25, 2026

When render? returns false, render_in returned a plain "" instead of "".html_safe, making it inconsistent with the happy path and causing TypeError when concatenating with other SafeBuffer strings.

Changes

  • lib/view_component/base.rb: Return "".html_safe instead of "" in the render? false branch
  • test/sandbox/test/rendering_test.rb: Add assertion that render_in output is html-safe when render? is false
# Before fix — raises TypeError when concatenated with SafeBuffer
render(MyComponent.new) + some_helper_returning_html  # => TypeError

# After fix
render(MyComponent.new).html_safe?  # => true

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Fix render_in to return html_safe empty string when render? is false Fix render_in returning non-html_safe string when render? is false Mar 25, 2026
Copilot AI requested a review from joelhawksley March 25, 2026 01:00
Copy link
Member

@joelhawksley joelhawksley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please add a changelog

@joelhawksley joelhawksley marked this pull request as ready for review March 25, 2026 15:03
@joelhawksley
Copy link
Member

@copilot please add a changelog entry

Copy link
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot please add a changelog entry

Added a changelog entry in docs/CHANGELOG.md under the ## main heading in commit 8733dad.

Copilot AI requested a review from joelhawksley March 25, 2026 15:08
@joelhawksley joelhawksley merged commit eacb45a into main Mar 25, 2026
18 checks passed
@joelhawksley joelhawksley deleted the copilot/fix-render-in-html-safe-output branch March 25, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render_in returns non-html_safe empty string when render? is false

2 participants