Only apply filter if not null
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 8.4k
- Forks
- 1.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 37
Description
@fprochazka suggested a BC change so that the date filter returns blank instead of the current date.
Currently you have to do
{{ user.birthday ? user.birthday|date('Y-m-d') : '' }}to avoid this.
Originally posted by @PrOF-kk in https://github.com/twigphp/Twig/issues/3951#issuecomment-2404415672
This got me thinking that a more generic solution would be to not apply filters to nulls, with a syntax similar to PHP's ?-> operator, like this;
{{ user.birthday?|date('Y-m-d') }}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading this proposal together with the referenced discussion in issue #3951, focusing on the suggested ?| syntax and its backward-compatibility implications. The work is done when the intended null-filter behavior and syntax are resolved and implemented consistently for Twig templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100