Skip to content

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

Open
@Andy9822

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions