- All Superinterfaces:
JStachioExtension
- All Known Implementing Classes:
JMustacheRenderer
Advises, intercepts or filters a template before being rendered.
This extension point is largely to support dynamic updates of templates where a template is being edited while the JVM is fully loaded and we need to intercept the call to provide rendering of the updated template.
The extension will only be executed if JStachio
render (and execute) methods
are used and not the generated classes render methods.
When JStachio renders a model through the runtime it:
- Loads the template. In some cases it may use reflection and thus
TemplateInfo
may not be a generatedTemplate
. - Loads the composite filter which is all the filters combined in order (see
order()
). - Creates the filter chain with the loaded template.
- Then tells the chain to process the rendering.
- Author:
- agentgt
- API Note
- ⚠ WARNING! While this extension point is public API it is recommended you do not use it. It is less stable than the rest of the API and is subject to change in the future. Implementations should be threadsafe!
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A fully composed chain that renders a model by applying filtering. -
Method Summary
Modifier and TypeMethodDescriptionstatic JStachioFilter
compose
(Iterable<JStachioFilter> filters) Creates a composite filter of a many filters.filter
(TemplateInfo template, JStachioFilter.FilterChain previous) Advises or filters a previously created filter.default int
order()
Hint on order of filter chain.
-
Method Details
-
filter
Advises or filters a previously created filter.- Parameters:
template
- info about the templateprevious
- the function returned early in the chain.- Returns:
- an advised render function or often the previous render function if no advise is needed.
-
order
Hint on order of filter chain. The foundJStachioFilter
s are sorted naturally (lower number comes first) based on the returned number. Thus the filter that has the greatest say is the filter with the highest number.- Returns:
- default returns zero
-
compose
Creates a composite filter of a many filters.- Parameters:
filters
- not null.- Returns:
- a composite filter ordered by
order()
-