Shopify / Shopify/liquid

Avoid parsing a variable to nil if not found

Open
#1,263 0 comments 0 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

I have two components A and B. A and B both have variables that are specific to their respective components. A template string is entered in A which is then passed to B and is then published. I want to use liquid to parse only the variables that are available in A and ignore the {{ }} syntax in the string if the variable is not found, so then when the string is passed to B, it can replace those variables.

" Hello {{ a.var }}. This is {{ b.var }} " -> [ Component A ] -> " Hello world. This is {{ b.var }} " -> [ Component B ] -> " Hello world. This is liquid "

I basically want to parse a string twice, without converting missing values to "". Is this possible with liquid right now?

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

The issue names no files, tests, or entry points. Start by locating the template parsing and missing-variable behavior, then reproduce the two-pass example; done means the first pass preserves the unresolved {{ b.var }} while resolving A's value, and the second pass resolves B's value.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.