KbPartialLoader

fun interface KbPartialLoader(source)

A caller-supplied loader that resolves a partial key to the KbTemplate to render in place of a {{> key }} tag.

Register an instance through KbEnvironmentBuilder.onLoadPartial. The loader is invoked lazily, only when a partial key is first encountered during a render; the resolved template is then cached on the environment, so the loader is asked at most once per distinct key for a given environment (across every render that reuses it).

Implementations may return null to signal that the key is unknown. For a static {{> symbol }} key an unknown result is a hard failure (a KbRenderException), because the key is fixed in the template source; for a dynamic {{> (expr) }} key an unknown result is a soft failure that emits nothing, because the key came from context data.

Functions

Link copied to clipboard
abstract fun load(key: String): KbTemplate?

Returns the KbTemplate to render for key, or null when key identifies no known partial.