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

Support the null coalescing operator #882

Closed
wisskid opened this issue Apr 30, 2023 · 0 comments
Closed

Support the null coalescing operator #882

wisskid opened this issue Apr 30, 2023 · 0 comments
Milestone

Comments

@wisskid
Copy link
Contributor

wisskid commented Apr 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant