Class TemplateData
Class containing all the data related to a template that is currently being processed.
Objects of this class are meant to be a part of the ITemplateContext
instances
offered by the engine to processing artifacts such as processors, pre-/post-processors, etc.
These objects contain some metadata about the template being processed, and also the template resource
itself, coming from the TemplateResolution
produced by template resolvers (ITemplateResolver
).
The template contained usually represents the template name, but can be the entire
template contents if the template has been resolved by a
StringTemplateResolver
or an analogous implementation of
ITemplateResolver
.
Objects of this class should not be considered thread-safe.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the template (usually the template name).Returns the template mode the template is being processed with.Returns the template resource.Returns the template selectors, if there are any.Returns the template resolution validity.boolean
Returns whether this spec has template selectors specified or not.
-
Method Details
-
getTemplate
Returns the template (usually the template name).
This template normally represents the template name, but can be the entire template contents if the template was specified as a String and resolved by a
StringTemplateResolver
or equivalent.- Returns:
- the template. Cannot be null.
-
hasTemplateSelectors
public boolean hasTemplateSelectors()Returns whether this spec has template selectors specified or not.
- Returns:
true
of there are template selectors,false
if not.
-
getTemplateSelectors
Returns the template selectors, if there are any.
Template selectors allow the possibility to process only a part of the specified template, expressing this selection in a syntax similar to jQuery, CSS or XPath selectors. Note this is only available for markup template modes (
HTML
,XML
). For more info on template selectors syntax, have a look at AttoParser's markup selectors documentation.- Returns:
- the template selectors, or
null
if there are none.
-
getTemplateResource
Returns the template resource.
Template resource instances are usually created by implementations of
ITemplateResolver
.Note that, even if this resource object will never be
null
, the existence of the resource object does not necessarily imply the existence of the resource itself unless the template resolver was configured for callingITemplateResource.exists()
upon template resolution.- Returns:
- the template resource. Cannot be null.
-
getTemplateMode
Returns the template mode the template is being processed with.
Most times this template mode is the one suggested by the
ITemplateResolver
that resolved the template, but in those times that a template mode was forced by specifying it at aTemplateSpec
object or at a call to theTemplateManager
, these will override the template mode suggested by the template resolver.- Returns:
- the template mode for the template. Cannot be null.
-
getValidity
Returns the template resolution validity.
This validity establishes whether the template can be included in the template cache, and also for how long its resolution will be considered valid.
When a cached template is not considered valid, its cache entry is discarded and it is resolved again.
- Returns:
- the validity object
-