Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing .to_s when rendering a node (dropped possibily by accident) #1893

Open
Andy9822 opened this issue Jan 14, 2025 · 0 comments
Open

Missing .to_s when rendering a node (dropped possibily by accident) #1893

Andy9822 opened this issue Jan 14, 2025 · 0 comments

Comments

@Andy9822
Copy link

Andy9822 commented Jan 14, 2025

Hey y'all,

I'm upgrading from Liquid v4 to v5 and encountered a subtle yet impactful breaking change that caused us a significant number of test failures. It seems that during a refactor, the call to .to_s for a node output was unintentionally (?) dropped.

If we travel back in time and look at black_body.rb from commit c2ef24, we can appreciate how it'd still explicitly call .to_s on the output of node#render unless the result was an array.
Image

However, while refactoring to improve rendering back in #1091 the new render_to_output_buffer dropped this, maybe by accident (?). Instead, it started "appending" the result of render directly to the output buffer without stringifying it.

Image

This causes this funny case where if your output returns a number, the << operation ends up adding a byte instead of the stringified value.
i.e.:

Image

@Andy9822 Andy9822 changed the title Missing .to_s when rendering a node Missing .to_s when rendering a node (dropped possibily by accident) Jan 14, 2025
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

No branches or pull requests

1 participant