Ternary operator feature support
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
I know this feature has been requested before in this thread: https://github.com/Shopify/liquid/issues/236
And based on 85 liking the idea, versus 2 not liking the idea says something.
But that issue was closed back in 2016, and as the docs says:
Things we will merge
- Features that are likely to be useful to the majority of Liquid users
I personally still see a great advantage in having the opportunity to use ternary operators, the code is way more slick and friendly to look at.
I saw the default filter was suggested, but doesn't always come in handy, when using logic.
Without ternary
{%- liquid
assign has_selected_variant = false
if product.selected_variant != nil
assign has_selected_variant = true
endif
-%}
With ternary
{%- assign has_selected_variant = product.selected_variant != nil ? true : false -%}
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
Start by reading the prior request in issue #236 and compare the provided “without ternary” and “with ternary” examples against current Liquid behavior. Define the supported syntax and acceptance tests before implementation; done means the ternary form works without breaking existing Liquid logic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100