- Type Parameters:
T
- the model type
- All Superinterfaces:
Renderer<T>
,TemplateInfo
- All Known Subinterfaces:
Template.EncodedTemplate<T>
,ViewableTemplate<T>
- All Known Implementing Classes:
ExampleModelRenderer
,HelloModelAndViewView
,HelloModelView
,HelloModelView
,MessagePageRenderer
,MessagePageRenderer
A JStachio Template is a renderer that has template meta data.
Generated code implements this interface.
While many of the methods allow passing in custom Escapers care must be taken to choose a proper escaper that supports the original media type and charset of the template. There is currently no runtime checking that the escaper supports the template's media type and charset.
- Author:
- agentgt
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
EXPERIMENTAL support of pre-encoded templates that have the static parts of the template already encoded into bytes.Nested classes/interfaces inherited from interface io.jstach.jstachio.TemplateInfo
TemplateInfo.TemplateSource
-
Field Summary
Fields inherited from interface io.jstach.jstachio.TemplateInfo
TEMPLATE_BINDING_NAME
-
Method Summary
Modifier and TypeMethodDescriptionRenders the passed in model to an appendable like output.default TemplateModel
Creates a template model pair.default <A extends Output.EncodedOutput<E>,
E extends Exception>
ARenders the passed in model directly to a binary stream possibly leveraging pre-encoded parts of the template.default void
write
(T model, OutputStream outputStream) Renders the passed in model directly to a binary stream using theTemplateInfo.templateCharset()
for encoding.Methods inherited from interface io.jstach.jstachio.TemplateInfo
description, lastLoaded, modelClass, normalizePath, supportsType, templateCharset, templateContentType, templateEscaper, templateFormatter, templateMediaType, templateName, templatePath, templateSource, templateString
-
Method Details
-
execute
Renders the passed in model to an appendable like output.- Specified by:
execute
in interfaceRenderer<T>
- Type Parameters:
A
- output typeE
- error type- Parameters:
model
- a model assumed never to benull
.appendable
- the appendable to write to.- Returns:
- the output passed in returned for convenience.
- Throws:
E
- if there is an error writing to the output- API Note
- if the eventual output is to be bytes use
write(Object, io.jstach.jstachio.Output.EncodedOutput)
as it will leverage pre-encoding if the template has it.
-
write
default <A extends Output.EncodedOutput<E>,E extends Exception> A write(T model, A output) throws E Renders the passed in model directly to a binary stream possibly leveraging pre-encoded parts of the template.- Type Parameters:
A
- output typeE
- error type- Parameters:
model
- a model assumed never to benull
.output
- to write to.- Returns:
- the passed in output for convenience
- Throws:
E
- if an error occurs while writing to output- API Note
- for performance and code generation reasons templates do not do validation that the encoded output has the correct charset.
-
write
Renders the passed in model directly to a binary stream using theTemplateInfo.templateCharset()
for encoding. If the template is pre-encoded the pre-encoded parts of the template will be written to the stream for performance otherwise anOutputStreamWriter
will wrap the outputstream.- Parameters:
model
- a model assumed never to benull
.outputStream
- to write to.- Throws:
IOException
- if an error occurs while writing to the outputStream- See Also:
- API Note
- The stream will not be closed but might be flushed by this call.
-
model
Creates a template model pair.- Parameters:
model
- nevernull
model.- Returns:
- executable template model pair.
-