Repository navigation
print: {{__index}} is the 1-based ordinal of a table / for row (#8610) - #8612
Merged
Merged
Conversation
A .print table or for loop had no way to print the row's ordinal, so the
line-number column an invoice items table starts with could not be expressed -
the binder exposed only the row's own fields.
The reserved {{__index}} now reads the 1-based position of the row among the
rows actually rendered: counted after the row filter (a filtered table numbers
the kept rows contiguously), and with groupBy the ordinal of the group. It
takes a format like any number, reads the innermost row where loops nest, and
renders empty outside a row.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Cause
A
.print<table source="items">/<for>had no way to print the row's ordinal: theDataBinderrow scope exposed only the row's own fields (plus the enclosing context), so the "№" column a standard invoice items table starts with was not expressible.Change
A reserved row variable,
{{__index}}(double underscore like__label, the other name the binder reserves):filter/match), so a filtered table numbers the kept rows 1, 2, 3 with no gaps.groupByit is the ordinal of the group (in the order the groups render).{{__index:00}}), composes with text.table/forcounts from 1 again. Outside a row it renders empty.__indexis not reachable.Implementation is confined to
DataBinder: the rowScopecarries its ordinal, assigned inrowScopesafter filtering and grouping, andScope.resolveOwnanswers__indexfrom it.Docs:
modules/parsers/document/README.md(next togroupBy),DataBinderclass javadoc,.claude/docs/document-templates.md.Verification
Run locally in a worktree:
mvn test -pl modules/parsers/document,components/engine/engine-document- parsers-document 155 tests, engine-document 82 tests, 0 failures. New: fiveDataBinderTestcases (table 1..n; filtered table andfornumbered contiguously; group ordinal; nested loops / restart per loop /<if>inside a row; format, reserved over a row field, empty outside a row) andXslFoRendererTest.rendersTheRowOrdinalColumnOfAnItemsTable(the acceptance template down to the XSL-FO cells).mvn -T 1C formatter:validatewith the formatter cache wiped - green.mvn -P release ... install -pl modules/parsers/document(javadoc) - green.Not verified: no integration test was run locally; no generator or template changed, so no
sample-intent-*fixture is affected.Fixes #8610
🤖 Generated with Claude Code