- All Known Subinterfaces:
Template<T>
,Template.EncodedTemplate<T>
,ViewableTemplate<T>
- All Known Implementing Classes:
ExampleModelRenderer
,HelloModelAndViewView
,HelloModelView
,HelloModelView
,MessagePageRenderer
,MessagePageRenderer
public interface TemplateInfo
Template meta data like its location, formatters, escapers and or its contents.
This data is usually available on generated Template
s.
- Author:
- agentgt
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Symbols representing where the template was retrieved from. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The template instance is accessible to mustache templates with this global binding name. -
Method Summary
Modifier and TypeMethodDescriptiondefault String
Utility method similar to toString that describes the template meta data.default long
The last loaded time if applicable.Class<?>
Return the model class (root context class annotated with JStache) that generated this template.default String
Normalizes the path to used byClassLoader.getResource(String)
.boolean
supportsType
(Class<?> type) Checks to see if a template supports the model class.The templateCharset
which is the original format of the template file and should ideally be used when encoding an HTTP response or similar.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 template media-type from theJStacheContentType
.The logical name of the template which maybe different thantemplatePath()
.If the template is a classpath resource file this will return the location that was originally resolved via config resolution.default TemplateInfo.TemplateSource
Where the template contents were retrieved from.default String
The raw contents of the template.
-
Field Details
-
TEMPLATE_BINDING_NAME
The template instance is accessible to mustache templates with this global binding name. This is not bound if template is typeJStacheType.STACHE
.- See Also:
-
-
Method Details
-
templateName
The logical name of the template which maybe different thantemplatePath()
.- Returns:
- logical name of template. Never null.
-
templatePath
If the template is a classpath resource file this will return the location that was originally resolved via config resolution.- Returns:
- the location of the template or empty if the template is inlined.
- See Also:
- API Note
- since the return is the original path resolved by the annotation processor
it may return a path with a starting "/" and thus it is recommend you call
normalizePath()
if you plan on loading the resource.
-
normalizePath
Normalizes the path to used byClassLoader.getResource(String)
. If the templatePath starts with a "/" it is stripped.- Returns:
- normalized path
-
templateString
The raw contents of the template. Useful if the template is inline. To determine if the template is actually inline usetemplateSource()
.- Returns:
- the raw contents of the template never null.
- See Also:
- API Note
- An empty or blank template string maybe a valid inline template and does not mean it is not inline.
-
templateContentType
Class<?> templateContentType()The template content type is the class annotated withJStacheContentType
which also describes the escaper to be used.- Returns:
- the template content type.
- API Note
- The class returned must be annotated with
JStacheContentType
.
-
templateCharset
The templateCharset
which is the original format of the template file and should ideally be used when encoding an HTTP response or similar. Furthermore ideally the template charset matches the chosentemplateContentType()
JStacheContentType.charsets()
otherwise the escaper may not appropriately escape.IF the template is inline or charset was not set this will usually be
StandardCharsets.UTF_8
.- Returns:
- the template Charset.
- See Also:
-
templateMediaType
The template media-type from theJStacheContentType
.- Returns:
- media type maybe an empty string.
-
templateEscaper
The escaper to be used on the template. SeeEscaper.of(Function)
. -
templateFormatter
Function<@Nullable Object,String> templateFormatter()The base formatter to be used on the template. SeeFormatter.of(Function)
. -
supportsType
Checks to see if a template supports the model class.- Parameters:
type
- the class of the model.- Returns:
- if this renderer supports the class.
-
modelClass
Class<?> modelClass()Return the model class (root context class annotated with JStache) that generated this template.- Returns:
- model class
-
templateSource
Where the template contents were retrieved from.- Returns:
- an enum never null.
-
lastLoaded
The last loaded time if applicable. For statically compiled templates this will always be a negative number. For dynamically loaded templates this more likely will return a non negative number indicating some hint of when the template was last modified or loaded.- Returns:
- the last modified or negative if not applicable
-
description
Utility method similar to toString that describes the template meta data.- Returns:
- description of the template.
-