Syntax sugar for default filter (AKA nullish coalescing)
Open
Nobody has claimed this yet.
Feature Request
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
With similar enthusiasm to #1264, I humbly request support for the nullish coalescing operator: ??.
With this, I can detect truthy frontmatter variables and apply them. Otherwise, I can apply a fallback value.
An example:
:D
{% assign page_title = page.slug ?? page.title %}
Without nullish coalescing:
D:
{% assign page_title = page.title %}
{% if page.slug %}{% assign page_title = page.slug %}{% endif %}
Contributor guide
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
No implementation files or tests are named. Start by reviewing the related #1264 discussion and the parser and evaluator paths for existing assignment and conditional syntax; done means ?? is accepted in the shown assignment and applies the fallback behavior described in the issue, with coverage for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100