Skip to content

Add Shopify Liquid v5.13 compatibility#62

Merged
cappuc merged 9 commits into
mainfrom
feat/shopify-5-13
Jul 10, 2026
Merged

Add Shopify Liquid v5.13 compatibility#62
cappuc merged 9 commits into
mainfrom
feat/shopify-5-13

Conversation

@cappuc

@cappuc cappuc commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add self drop support so templates can read self.foo, self[key], and pass self across render boundaries with correct scope behavior.
  • Harden tag parsing for assign, capture, increment, and decrement so dotted and bracketed targets now fail at parse time.
  • Update README and changelog for the v0.11.0 / Shopify Liquid v5.13 compatibility release.
  • Add integration coverage for self lookup behavior, nested partials, null handling, and parser rejection cases.

Testing

  • Added integration tests in tests/Integration/SelfDropTest.php covering property lookup, bracket lookup, partial scope isolation, and regression cases.
  • Added parser rejection tests in tests/Integration/Tags/AssignTagTest.php, tests/Integration/Tags/CaptureTagTest.php, and tests/Integration/Tags/IncrementTagTest.php.
  • Not run

cappuc and others added 9 commits July 10, 2026 14:46
Reject dotted and bracketed assignment targets in assign, capture,
increment, and decrement at parse time. Previously these were silently
accepted but produced unreachable state (e.g. {% assign foo.bar = "x" %}
set a flat key "foo.bar" invisible to normal variable lookup).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…atibility

SelfDrop is a proxy object that resolves property lookups through the
current render context's scope chain. It does not implement IsContextAware,
so a SelfDrop passed explicitly to a partial via `render` retains its
original context rather than being rebound to the partial's isolated scope.

RenderContext caches one SelfDrop per context instance so that repeated
`self` lookups within the same context return the identical PHP object,
making === equality work through the existing condition evaluation logic.

The fallback is injected in findVariables() only when no value at all was
found for key "self". An explicit `{% assign self = nil %}` leaves [null]
in the variable list, so the SelfDrop fallback is correctly skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…0.11.0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add four tests that were in Shopify's self_drop_context_test.rb but not
previously ported:

- Same-variable-name collision across render boundary: passed self holds
  caller's value while partial's implicit self holds its own (42|43)
- Three-level nested render with the same variable shadowed at each level:
  outer.a|middle.a|self.a = 1|2|3
- Assigned self compares equal to itself (s == s)
- Defined key on self resolves correctly under strict variables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add shared simple-variable validation for assign, capture, and increment
- reject invalid capture and expression syntax with updated tests
…ries

Add SyntaxException::expectedSimpleVariable() and tagSyntaxException() so
the generic "expected a plain variable name" signal is raised in one place
(TokenStream::simpleVariableName) and each tag enriches it with its own
valid-syntax hint on catch, rather than each tag owning its full error string.

- Remove SYNTAX_ERROR constants from AssignTag and CaptureTag
- Narrow AssignTag's broad catch to just the simpleVariableName() call
- Use static::tagName() in IncrementTag so DecrementTag inherits correctly
- Chain the original SyntaxException as $previous for debuggability
- Update all test expectations to the new message format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `self` drop support for scoped lookups and render boundaries
- Reject dotted and bracketed assign/capture/increment targets earlier
- Update syntax errors and integration coverage
- Wrap tag parsers with consistent syntax context
- Update invalid-usage messages and tests to use angle-bracket syntax
@cappuc
cappuc merged commit 53db5a3 into main Jul 10, 2026
26 checks passed
@cappuc
cappuc deleted the feat/shopify-5-13 branch July 10, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant