Package io.quarkus.qute
Interface TemplateInstance
-
- All Known Implementing Classes:
TemplateInstanceBase
public interface TemplateInstanceRepresents an instance ofTemplate.This construct is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTemplateInstance.InitializerThis component can be used to initialize a template instance, i.e.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CompletionStage<Void>consume(Consumer<String> consumer)Triggers rendering.io.smallrye.mutiny.Multi<String>createMulti()Create a newMultithat can be used to consume chunks of the rendered template.io.smallrye.mutiny.Uni<String>createUni()Create a newUnithat can be used to consume the rendered template.TemplateInstancedata(Object data)Set the the root data object.TemplateInstancedata(String key, Object data)Put the data in a map.ObjectgetAttribute(String key)default TemplategetFragment(String id)TemplategetTemplate()longgetTimeout()TemplateInstanceonRendered(Runnable action)Register an action that is performed after the rendering is finished.Stringrender()Triggers rendering.CompletionStage<String>renderAsync()Triggers rendering.TemplateInstancesetAttribute(String key, Object value)
-
-
-
Field Detail
-
TIMEOUT
static final String TIMEOUT
Attribute key - the timeout forrender()in milliseconds.- See Also:
getTimeout(), Constant Field Values
-
VARIANTS
static final String VARIANTS
Attribute key - all template variants found.- See Also:
- Constant Field Values
-
SELECTED_VARIANT
static final String SELECTED_VARIANT
Attribute key - a selected variant.- See Also:
- Constant Field Values
-
-
Method Detail
-
data
TemplateInstance data(Object data)
Set the the root data object. Invocation of this method removes any data set previously bydata(String, Object).- Parameters:
data-- Returns:
-
data
TemplateInstance data(String key, Object data)
Put the data in a map. The map will be used as the root context object during rendering. Invocation of this method removes the root data object previously set bydata(Object).- Parameters:
key-data-- Returns:
- self
-
setAttribute
TemplateInstance setAttribute(String key, Object value)
- Parameters:
key-value-- Returns:
- self
-
render
String render()
Triggers rendering. Note that this method blocks the current thread!- Returns:
- the rendered template as string
-
renderAsync
CompletionStage<String> renderAsync()
Triggers rendering.- Returns:
- a completion stage that is completed once the rendering finished
-
createMulti
io.smallrye.mutiny.Multi<String> 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
io.smallrye.mutiny.Uni<String> 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
CompletionStage<Void> consume(Consumer<String> consumer)
Triggers rendering.- Parameters:
consumer- To consume chunks of the rendered template- Returns:
- a completion stage that is completed once the rendering finished
-
getTimeout
long getTimeout()
- Returns:
- the timeout
- See Also:
TIMEOUT
-
getTemplate
Template getTemplate()
- Returns:
- the original template
-
getFragment
default Template getFragment(String id)
- Parameters:
id-- Returns:
- the fragment or
null - See Also:
Template.getFragment(String)
-
onRendered
TemplateInstance onRendered(Runnable action)
Register an action that is performed after the rendering is finished.- Parameters:
action-- Returns:
- self
-
-