Repository navigation
WIP5 - #2134
Closed
charlespwd wants to merge 2 commits into
Closed
WIP5#2134charlespwd wants to merge 2 commits into
charlespwd wants to merge 2 commits into
Conversation
|
@charlespwd platform-grade prior art over in Mechanic: https://learn.mechanic.dev/platform/liquid/keyword-literals/array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Research / WIP
Experimental output from
liquid-factory, shared for design and code feedback. This is a research draft for the WIP3 stack, not a merge-ready language change.In this PR
Add array literals to the native shared expression grammar, including nested arrays and trailing commas.
Problem
Templates build fixed lists with
'top,bottom' | split: ','and empty lists with'' | split: ','.Solution
Templates can write
{% assign rows = ['top', 'bottom'] %}or use literals directly in filters, conditions, loops and render arguments.ArrayLiteralevaluates its elements in the current context and returns a fresh container. Tags reuse the shared parser, so no tag-specific array implementation is needed. A leading[constructs an array in every shared-parser call, with noreject_bare_bracketsoption or legacy unnamed-bracket branch.Paired specs: Shopify/liquid-spec#169, adding
specs/liquid_ruby/array_literals.yml.Ruby API migration
Remove
reject_bare_brackets:fromParser.newcalls. The shared parser now has one leading-bracket grammar, including inContext#[]:context['[key]']evaluates an array containing the value ofkey.context['self[key]']for the indirect variable lookup previously expressed by bare brackets.Existing native-template results stay unchanged. Typed legacy lookup-string APIs remain separate; this change does not add a replacement parser mode.
Feature boundary
Outcome
Construct an Array directly with
[]or[expression, ...]wherever the native parser accepts an expression.Scope
Context#[]now use the same array grammar for leading brackets;self[...]remains explicit lookup.Acceptance boundary
specs/liquid_ruby/array_literals.ymlcontains the approved preservation, constructor and malformed-input cases.test/integration/array_literal_test.rb.[1, 2][0]remain syntax errors.Non-goals
Hash literals, mixed array/hash literal nesting, arithmetic, filtered parentheses, interpolation, new postfix grammar and changes to for-argument separators.
Dependencies
liquid-factory-shared-expressions-in-forat372f77cbebd9c9c5319d967a1a988d7c5878b225.736ebca7b4377dbd8bf59232649fa00c69b21ea3.The cases are examples, not proof that every possible template preserves its output.