Module io.jstach.opt.spring.example
Class MessagePageRenderer
java.lang.Object
io.jstach.opt.spring.example.message.MessagePageRenderer
- All Implemented Interfaces:
Renderer<io.jstach.opt.spring.example.message.MessagePage>
,JStachioFilter.FilterChain
,TemplateProvider
,Template<io.jstach.opt.spring.example.message.MessagePage>
,TemplateInfo
@Component
public class MessagePageRenderer
extends Object
implements Template<io.jstach.opt.spring.example.message.MessagePage>, TemplateInfo, TemplateProvider, JStachioFilter.FilterChain
Generated Renderer.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jstach.jstachio.TemplateInfo
TemplateInfo.TemplateSource
-
Constructor Summary
ConstructorDescriptionRenderer constructor for reflection (use of() instead).MessagePageRenderer
(TemplateConfig templateConfig) Renderer constructor using config.Renderer constructor for manual wiring. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(io.jstach.opt.spring.example.message.MessagePage model, Appendable a) Renders the passed in model.void
execute
(io.jstach.opt.spring.example.message.MessagePage model, Appendable a, Formatter formatter, Escaper escaper) Renders the passed in model.Class<?>
Model class.static MessagePageRenderer
of()
Convience static factory that will reuse the same singleton instance.static <A extends Appendable>
voidrender
(io.jstach.opt.spring.example.message.MessagePage data, A unescapedWriter, Formatter formatter, Appender<? super A> escaper, Appender<A> appender) Renders the passed in model.boolean
supportsType
(Class<?> type) Checks to see if a template supports the model class.Appender.Class<?>
The template content type is the class annotated withJStacheContentType
which also describes the escaper to be used.The escaper to be used on the template.The base formatter to be used on the template.The logical name of the template which maybe different thanTemplateInfo.templatePath()
.If the template is a classpath resource file this will return the location that was originally resolved viaconfig resolution
.The raw contents of the template.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jstach.jstachio.TemplateInfo
description, lastLoaded, normalizePath, templateSource
Methods inherited from interface io.jstach.jstachio.spi.TemplateProvider
provideTemplates
-
Constructor Details
-
MessagePageRenderer
Renderer constructor for manual wiring.- Parameters:
formatter
- formatter if null the static formatter will be used.escaper
- escaper if null the static escaper will be used
-
MessagePageRenderer
public MessagePageRenderer()Renderer constructor for reflection (use of() instead). For programmatic consider usingof()
for a shared singleton. -
MessagePageRenderer
Renderer constructor using config.- Parameters:
templateConfig
- config that has collaborators
-
-
Method Details
-
execute
public void execute(io.jstach.opt.spring.example.message.MessagePage model, Appendable a) throws IOException Description copied from interface:Template
Renders the passed in model.- Specified by:
execute
in interfaceRenderer<io.jstach.opt.spring.example.message.MessagePage>
- Specified by:
execute
in interfaceTemplate<io.jstach.opt.spring.example.message.MessagePage>
- Parameters:
model
- a model assumed never to benull
.a
- the appendable to write to.- Throws:
IOException
- if there is an error writing to the appendable
-
execute
public void execute(io.jstach.opt.spring.example.message.MessagePage model, Appendable a, Formatter formatter, Escaper escaper) throws IOException Description copied from interface:Template
Renders the passed in model.- Specified by:
execute
in interfaceTemplate<io.jstach.opt.spring.example.message.MessagePage>
- Parameters:
model
- a model assumed never to benull
.a
- appendable to write to.formatter
- formats variables before they are passed to the escaperescaper
- used to write escaped variables- Throws:
IOException
- if an error occurs while writing to the appendable
-
supportsType
Description copied from interface:TemplateInfo
Checks to see if a template supports the model class.- Specified by:
supportsType
in interfaceTemplateInfo
- Parameters:
type
- the class of the model.- Returns:
- if this renderer supports the class.
-
templatePath
Description copied from interface:TemplateInfo
If the template is a classpath resource file this will return the location that was originally resolved viaconfig resolution
.- Specified by:
templatePath
in interfaceTemplateInfo
- Returns:
- the location of the template or empty if the template is inlined.
- See Also:
-
templateName
Description copied from interface:TemplateInfo
The logical name of the template which maybe different thanTemplateInfo.templatePath()
.- Specified by:
templateName
in interfaceTemplateInfo
- Returns:
- logical name of template. Never null.
-
templateString
Description copied from interface:TemplateInfo
The raw contents of the template. Useful if the template is inline. To determine if the template is actually inline useTemplateInfo.templateSource()
.- Specified by:
templateString
in interfaceTemplateInfo
- Returns:
- the raw contents of the template never null.
- See Also:
-
templateContentType
Description copied from interface:TemplateInfo
The template content type is the class annotated withJStacheContentType
which also describes the escaper to be used.- Specified by:
templateContentType
in interfaceTemplateInfo
- Returns:
- the template content type.
-
templateEscaper
Description copied from interface:TemplateInfo
The escaper to be used on the template. SeeEscaper.of(Function)
.- Specified by:
templateEscaper
in interfaceTemplateInfo
- Returns:
- the escaper.
- See Also:
-
templateFormatter
Description copied from interface:TemplateInfo
The base formatter to be used on the template. SeeFormatter.of(Function)
.- Specified by:
templateFormatter
in interfaceTemplateInfo
- Returns:
- the formatter.
- See Also:
-
templateAppender
Appender.- Returns:
- appender for writing unescaped variables.
-
modelClass
Model class.- Specified by:
modelClass
in interfaceTemplate<io.jstach.opt.spring.example.message.MessagePage>
- Returns:
- class used as model (annotated with JStache).
-
of
Convience static factory that will reuse the same singleton instance.- Returns:
- renderer same as calling no-arg constructor but is cached with singleton instance
-
render
public static <A extends Appendable> void render(io.jstach.opt.spring.example.message.MessagePage data, A unescapedWriter, Formatter formatter, Appender<? super A> escaper, Appender<A> appender) throws IOException Renders the passed in model.- Type Parameters:
A
- appendable type.- Parameters:
data
- modelunescapedWriter
- appendable to write to.formatter
- formats variables before they are passed to the escaper.escaper
- used to write escaped variables.appender
- used to write unescaped variables.- Throws:
IOException
- if an error occurs while writing to the appendable
-