feat: dictionary iteration and computed key access#3
Merged
Conversation
Add IndexAccessExpression AST node, Pratt parser postfix operator for bracket notation, and evaluator support for dynamic key/index access on ObjectValue and ArrayValue.
RoboNET
added a commit
that referenced
this pull request
Mar 11, 2026
* feat(ast): add LoopKey to TemplateContext for dictionary iteration * feat(ast): add @key loop variable to ExpressionEvaluator * feat(ast): add ObjectValue iteration to TemplateExpander * feat(ast): add ObjectValue iteration to inline {{#each}} blocks * feat(ast): trim keys in SetLoopKey to ensure clean @key values * feat(ast): trim keys in ObjectValue for consistent key handling * feat(ast): add computed key access [expr] to expression system Add IndexAccessExpression AST node, Pratt parser postfix operator for bracket notation, and evaluator support for dynamic key/index access on ObjectValue and ArrayValue. * test: add end-to-end integration tests for dictionary iteration with computed key access Add scope walking to ExpressionEvaluator.Resolve so variables from parent scopes (e.g. root data) are accessible inside each loops. This enables patterns like {{values[@key]}} where @key comes from the loop and values lives at root level. * docs: fix inverted XML doc comment on TemplateContext.Scopes * docs: add dictionary iteration and computed key access to wiki
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.
Summary
type: eachand{{#each}}auto-detect ObjectValue and iterate key-value pairs with@key,@index,@first,@lastloop variablesdict[expr]postfix operator in Pratt parser — supports variables, string literals, expressions, filters, and nested bracketsTest Plan