Repository navigation
Add value slots to the generated element API - #2
Merged
Merged
Conversation
textOf/rawOf/intOf/longOf/doubleOf/boolOf/attrOf/attrOfNullable bind a single value from the model without a dynamic() block. forEachOf and whenOf preencode loops and conditionals the same way. A Slot<M> scope object fixes the model type for a block's lambdas, since the slot methods otherwise take an unbounded type parameter. Also generates a primitive overload for numeric attribute setters, avoiding a box before String.valueOf.
BernardoPe
force-pushed
the
feat/value-slots
branch
from
October 9, 2026 07:47
fc9dfdb to
e88cb07
Compare
Like forEachOf, but each item comes with its position, starting at 0, as an Indexed<E> with item() and index(). Templates that number rows or alternate row classes no longer need to build a wrapper list per render. The items are paired lazily as the loop reaches them.
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.
This adds value slots to the generated element API.
The new
textOf,rawOf,intOf,longOf,doubleOf,boolOf,attrOfandattrOfNullablemethods allow a single value to be read from the model without using adynamic()block.forEachOfandwhenOfuse the same approach for loops and conditionals. Their bodies receive aSlot<M>so the model type can be inferred correctly inside the lambda.Slotprovidesread,readInt,readLong,readDoubleandreadBool, which return the accessor unchanged and only exist to provide the type information needed by the lambda.The changes are additive, so existing implementations of
ElementVisitorBasedo not need to implement any new methods.Numeric attribute setters also get primitive overloads, for example
attrColspan(int), so callers do not need to box a value before converting it to a string.This is used by HtmlFlow#149.