Skip to content

KaRenderingContext

The rendering state passed to every KaPieceRenderer, used to render nested pieces and to read KaRenderingOption values.

Functions

isInside

abstract fun <T> isInside(piece: KaPiece<T>): Boolean

Whether the current renderer has been requested by piece (possibly transitively).

The piece which the current renderer renders is not a requester of itself. Passing that piece therefore detects nesting, such as a KaPiece.Type which is rendered as a type argument of another KaPiece.Type.

render

context(session: KaSession)
abstract fun <T> render(value: T, piece: KaPiece<T>)

Renders value as the given piece, dispatching to the corresponding renderer stack.

context(session: KaSession)
abstract fun <T> render(
    value: T, 
    piece: KaPiece<T>, 
    output: KaRenderingOutput
)

Renders value as the given piece, dispatching to the corresponding renderer stack, but writes the result into output instead of the output of the current rendering. Nested pieces are written into output as well.

This allows a renderer to capture the rendered form of a piece, e.g. to post-process it or to render it as a single fragment.

valueFor

abstract fun <T> valueFor(option: KaRenderingOption<T>): T

Returns the effective value of option for this renderer (the overridden value, or its KaRenderingOption.defaultValue).