Skip to content

Support the null coalescing operator #882

@wisskid

Description

@wisskid

Smarty has no support for the null coalescing operator. One might argue that it is not required, since the default modifier largely serves the same purpose. However, the default modifier is also triggered by an empty string: '', whereas the null coalescing operator would only replace a null value and leave everything else untouched.

Example:

{$myvar ?? 'undefined'}

This would render as 'undefined' if and only if:

  • myvar is undefined, or
  • myvar is set to null
  • myvar is set to 'undefined'

Otherwise, it should return the value set for myvar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions