Skip to content

Add strict null coalescing operator #1454

@marcorieser

Description

@marcorieser

The null coalescing operator in Antlers behaves differently than in PHP land. It checks for truthy values, rather than for strict null. Most of the time, that's perfectly fine and desired, but sometimes I really want to keep an empty string.

For example, <input type="text" value="{{ old.shipping_line_2 ?? 'Fallback' }}" /> in a form, when many fields were submitted and old.shipping_line_2 was submitted empty, I want to keep the empty value.

In Discord, @andjsch had the idea of a strict ??? operator in Antlers that does what PHP does.

Metadata

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