Shopify / Shopify/liquid

Ternary operator

Open
#2,033 0 comments 21 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

  • AS A software engineer writing a Liquid template,
  • I WANT TO use a ternary operator to assign values for truthy or falsey scenarios,
  • SO THAT I can write this in one line instead of five.
- {% if url == "/" %}
-   {% assign my_variable = "something" %}
- {% else %}
-   {% assign my_variable = "something_else" %}
- {% endif %}
+ {% assign my_variable = url == "/" ? "something" : "something_else" %}

There is a huge amount of support for this crucial feature in twelve-year-old issue #236.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the requested syntax and prior discussion in issue #236, then locate the parser and assignment handling for Liquid expressions. Done means the shown ternary expression supports truthy and falsey values and has coverage demonstrating both branches.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.