-
Notifications
You must be signed in to change notification settings - Fork 68
Feature/assign dot notation #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Jekyll-compatible dot notation support for assign tags, allowing syntax like {% assign page.canonical_url = "/about/" %} when Jekyll extensions are enabled. This feature is hidden behind a configuration flag to maintain backward compatibility with standard Shopify Liquid.
Key changes:
- Added
JekyllExtensionsconfiguration option to control dot notation support - Modified assign tag parser to handle nested property paths
- Added
SetPathmethod to render context for setting nested object properties
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| engine.go | Added EnableJekyllExtensions() method to configure Jekyll compatibility |
| render/config.go | Added JekyllExtensions boolean field to Config struct |
| render/context.go | Implemented SetPath method for setting values at nested object paths |
| expressions/statements.go | Extended Assignment struct to support property paths alongside simple variables |
| expressions/expressions.y | Modified grammar to parse dot notation in assign targets |
| expressions/y.go | Generated parser code reflecting grammar changes |
| tags/standard_tags.go | Refactored assign tag to use configuration-aware factory function |
| tags/standard_tags_test.go | Added comprehensive tests for Jekyll extensions functionality |
| README.md | Added documentation for Jekyll compatibility features |
| Multiple test files | Updated function calls to match new AddStandardTags signature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
c8db49d to
eceaefa
Compare
Implements #113 - Support assigning to object properties with dot notation Changes: - Updated Assignment struct to support property paths - Modified parser grammar to accept dot notation (e.g., page.canonical_url) - Added SetPath method to context for nested property setting - Updated assignTag to handle both simple and dotted assignments - Added comprehensive tests for the new functionality This allows templates to use: {% assign page.canonical_url = page.url %} {% assign obj.nested.property = value %} Maintains backward compatibility with simple assignments.
…s flag Fixes #113 with proper Shopify Liquid compatibility Changes: - Added JekyllExtensions flag to render.Config (default: false) - Added EnableJekyllExtensions() method to Engine API - Dot notation in assign tags now requires Jekyll extensions to be enabled - Standard mode (default) maintains strict Shopify Liquid compatibility - Jekyll mode enables extensions for Jekyll/Gojekyll compatibility Behavior: - Standard mode: {% assign obj.prop = value %} is a syntax error - Jekyll mode: {% assign obj.prop = value %} creates/updates nested properties - Simple assignments work in both modes: {% assign var = value %} This approach ensures backward compatibility while allowing Jekyll-specific features to be enabled when needed for Gojekyll and other Jekyll-compatible implementations.
880c139 to
06417ca
Compare
- Added Unreleased section to CHANGELOG.md with recent features: - Jekyll Extensions Support (PR #114) - Auto-Escape Feature (PR #111) - Modernized Build Tooling (PR #115) - Added steve-ky as contributor for ideas/feedback on PR #89 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated CHANGELOG.md to include all merged PRs since version 1.3.0 (2020-02-13): Added features: - Jekyll Extensions Support (#114) - Auto-Escape Feature (#111) - Template Loader (#107) - BasicEngine (#104) - JSON Filter (#84) - Strict Variables Mode (#74) - Custom Writer Support (#86) - Template AST Access (#59, #66) - For-Else Support (#93) - Unless-Else Support (#68) - General Range Expressions (#65) - Loop Modifier Expressions (#67) Fixes: - Size filter, slice bounds, division by zero - Nil pointer handling - Whitespace control - Multiline slice - Block errors - Map filter with structs - And more Also added steve-ky as contributor for ideas/feedback on PR #89. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Checklist
make testpasses.make lintpasses.Description
This PR adds support for Jekyll-compatible dot notation in the
{% assign %}tag, allowing nested property assignment like{% assign page.canonical_url = "/about/" %}. This feature is gated behind theJekyllExtensionsconfiguration flag to maintain backward compatibility.Changes
Core Implementation
obj.property = value)SetPath()method to the render context for setting nested valuesJekyllExtensionsflag is set to trueParser Changes
expressions.ygrammar to parse dot notation in assign targetsAssignmentstruct to include bothVariable(for simple assignments) andPath(for dot notation)Safety & Validation
Testing
Comprehensive test coverage has been added in
TestAssignTag_JekyllExtensions:new_obj.propwhennew_objdoesn't exist)Examples
With Jekyll extensions enabled:
{% assign page.canonical_url = "/about/" %} {% assign page.meta.description = "Test description" %} {% assign new_obj.nested.deep = "value" %}Without Jekyll extensions (standard mode):
{% assign simple_var = "value" %} // ✅ Works {% assign obj.prop = "value" %} // ❌ Error: requires Jekyll extensionsBreaking Changes
None - the feature is opt-in via the
JekyllExtensionsconfiguration flag.