Package io.quarkus.qute
Interface TemplateInstance
- All Known Implementing Classes:
ForwardingTemplateInstance,ResultsCollectingTemplateInstance,TemplateInstanceBase
public interface TemplateInstance
Represents an instance of
Template.
This construct is not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThis component can be used to initialize a template instance, i.e. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault TemplateInstancecomputedData(String key, Function<String, Object> function) Associates the specified mapping function with the specified key.default CompletionStage<Void>Triggers rendering.default io.smallrye.mutiny.Multi<String>Create a newMultithat can be used to consume chunks of the rendered template.default io.smallrye.mutiny.Uni<String>Create a newUnithat can be used to consume the rendered template.default TemplateInstanceSet the the root data object.default TemplateInstancePut the data in a map.default ObjectgetAttribute(String key) default TemplategetFragment(String id) default Templatedefault longdefault TemplateInstanceonRendered(Runnable action) Register an action that is performed after the rendering is finished.default Stringrender()Triggers rendering.default CompletionStage<String>Triggers rendering.default TemplateInstancesetAttribute(String key, Object value) default TemplateInstanceSets thelocaleattribute that can be used to localize parts of the template, i.e.default TemplateInstanceSets thelocaleattribute that can be used to localize parts of the template, i.e.default TemplateInstancesetVariant(Variant variant) Sets the variant attribute that can be used to select a specific variant of the template.
-
Field Details
-
TIMEOUT
Attribute key - the timeout forrender()in milliseconds.- See Also:
-
VARIANTS
Attribute key - all template variants found.- See Also:
-
SELECTED_VARIANT
Attribute key - a selected variant.- See Also:
-
LOCALE
Attribute key - locale.- See Also:
-
-
Method Details
-
data
Set the the root data object. Invocation of this method removes any data set previously bydata(String, Object)andcomputedData(String, Function).- Parameters:
data-- Returns:
-
data
Put the data in a map. The map will be used as the root context object during rendering. Remove the root data object previously set bydata(Object).- Parameters:
key-data-- Returns:
- self
-
computedData
Associates the specified mapping function with the specified key. The function is applied each time a value for the given key is requested. Also removes the root data object previously set bydata(Object).If the key is already associated with a value using the
data(String, Object)method then the mapping function is never used.- Parameters:
key-function-- Returns:
- self
-
setAttribute
- Parameters:
key-value-- Returns:
- self
-
getAttribute
- Parameters:
key-- Returns:
- the attribute or null
-
render
Triggers rendering. Note that this method blocks the current thread!- Returns:
- the rendered template as string
-
renderAsync
Triggers rendering.- Returns:
- a completion stage that is completed once the rendering finished
-
createMulti
Create a newMultithat can be used to consume chunks of the rendered template. In particular, each item represents a part of the rendered template.This operation does not trigger rendering. Instead, each subscription triggers a new rendering of the template.
- Returns:
- a new Multi
- See Also:
-
Multi.subscribe()
-
createUni
Create a newUnithat can be used to consume the rendered template.This operation does not trigger rendering. Instead, each subscription triggers a new rendering of the template.
- Returns:
- a new Uni
- See Also:
-
Uni.subscribe()
-
consume
Triggers rendering.- Parameters:
consumer- To consume chunks of the rendered template- Returns:
- a completion stage that is completed once the rendering finished
-
getTimeout
default long getTimeout()- Returns:
- the timeout
- See Also:
-
getTemplate
- Returns:
- the original template
-
getFragment
- Parameters:
id-- Returns:
- the fragment or
null - See Also:
-
onRendered
Register an action that is performed after the rendering is finished.- Parameters:
action-- Returns:
- self
-
setLocale
Sets thelocaleattribute that can be used to localize parts of the template, i.e. to specify the locale for all message bundle expressions in the template.- Parameters:
locale- a language tag- Returns:
- self
-
setLocale
Sets thelocaleattribute that can be used to localize parts of the template, i.e. to specify the locale for all message bundle expressions in the template.- Parameters:
locale- aLocaleinstance- Returns:
- self
-
setVariant
Sets the variant attribute that can be used to select a specific variant of the template.- Parameters:
variant- the variant- Returns:
- self
-