- All Implemented Interfaces:
JStachioExtension
,JStachioExtensionProvider
,JStachioFilter
You are probably asking yourself why do I need JMustache if I have JStachio? Unfortunately JStachio needs the annotation processor to run every time a template is changed!. While there are incremental compilers like Eclipse that do support incrementally compiling annotations they are often not triggered via editing resources. Furthermore incremental compilation often just doesn't work.
Enter JMustache. Through reflection you can edit your templates while an application is
running. Luckily JMustache and JStachio are almost entirely compatible especially
through this extension which configures JMustache to act like JStachio. Even
JStacheLambda
will work.
The only major compatibility issue is that JMustache currently does not support mustache inheritance (parents and blocks)!
If this extension is enabled which it is by default if the ServiceLoader finds it
JMustache will be used when a runtime filtered rendering call is made (see
JStachio
).
How this works is this extension is a filter that checks to see if the statically
generated renderer (template) can render and that its template is up-to-date. If it is
not then JMustache will use the template meta data to construct its own template and
then execute it. In some cases the annotation processor does not even have to run for
this to work (see Templates.getInfoByReflection(Class)
.
Strongly recommended you disable this in production via
JSTACHIO_JMUSTACHE_DISABLE
or use
- Author:
- agentgt
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jstach.jstachio.spi.JStachioFilter
JStachioFilter.FilterChain
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
execute
(Object context, Appendable a, TemplateInfo template, boolean broken) Deprecated.Execute the template engine.filter
(TemplateInfo template, JStachioFilter.FilterChain previous) Advises or filters a previously created filter.void
init
(JStachioConfig config) Deprecated.Called before the extensions are used but afterJStachioExtensionProvider.provideConfig()
.protected void
log
(boolean flag) Deprecated.Log plugin on reload.protected void
log
(TemplateInfo template) Deprecated.Log template execution through jmustacheDeprecated.A prefix to add to the output to know that JMustache is being used.final @NonNull JStachioFilter
Provide a filter or not.sourcePath
(String sourcePath) Deprecated.Sets the relative to the project sourcePath for runtime lookup of templates.Deprecated.A suffix to append to the output to know that JMustache is being used.use
(boolean flag) Deprecated.Enables JMustacheMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jstach.jstachio.spi.JStachioExtensionProvider
provideConfig, provideTemplateFinder
Methods inherited from interface io.jstach.jstachio.spi.JStachioFilter
order
-
Field Details
-
JSTACHIO_JMUSTACHE_SOURCE_PATH
Deprecated.Property key of where jmustache will try to load template files. Default issrc/main/resources
.- See Also:
-
JSTACHIO_JMUSTACHE_DISABLE
Deprecated.Property key to disable jmustache. Default isfalse
.- See Also:
-
-
Constructor Details
-
JMustacheRenderer
public JMustacheRenderer()Deprecated.No-arg constructor for ServiceLoader
-
-
Method Details
-
use
Deprecated.Enables JMustache- Parameters:
flag
- true enables- Returns:
- return this for builder like config
-
prefix
Deprecated.A prefix to add to the output to know that JMustache is being used.- Parameters:
prefix
- string to prefix output- Returns:
- return this for builder like config
-
suffix
Deprecated.A suffix to append to the output to know that JMustache is being used.- Parameters:
suffix
- string to suffix output- Returns:
- return this for builder like config
-
sourcePath
Deprecated.Sets the relative to the project sourcePath for runtime lookup of templates. By default issrc/main/resources
.- Parameters:
sourcePath
- by default issrc/main/resources
- Returns:
- sourcePath should not be null
-
log
Deprecated.Log plugin on reload.- Parameters:
flag
- true is if extension is enabled.
-
log
Deprecated.Log template execution through jmustache- Parameters:
template
- template to execute.
-
init
Deprecated.Description copied from interface:JStachioExtensionProvider
Called before the extensions are used but afterJStachioExtensionProvider.provideConfig()
. SeeJStachioExtensionProvider.provideConfig()
on how the config is consolidated to a single config.- Parameters:
config
- the composite config never null
-
execute
protected boolean execute(Object context, Appendable a, TemplateInfo template, boolean broken) throws IOException Deprecated.Execute the template engine. If the engine chooses not to participatefalse
should be returned.- Parameters:
context
- the modela
- the appendable to write totemplate
- template infobroken
- whether or no the previous filter (usually jstachio itself) is broken.- Returns:
true
if the engine has written to the appendable- Throws:
IOException
- error writing to the appendable
-
filter
public JStachioFilter.FilterChain filter(TemplateInfo template, JStachioFilter.FilterChain previous) Description copied from interface:JStachioFilter
Advises or filters a previously created filter.- Specified by:
filter
in interfaceJStachioFilter
- 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.
-
provideFilter
Provide a filter or not. The final filter is a composite and becomes a filter chain. The implementation is a filter and provides itself.- Specified by:
provideFilter
in interfaceJStachioExtensionProvider
- Returns:
- filter if this service provider provies one or
null
-