Class JMustacheRenderer

java.lang.Object
io.jstach.opt.jmustache.JMustacheRenderer
All Implemented Interfaces:
JStachioExtension, JStachioExtensionProvider, JStachioFilter

@MetaInfServices(JStachioExtension.class) public class JMustacheRenderer extends Object
Use JMustache instead of JStachio for rendering. The idea of this extension is to allow you to edit Mustache templates in real time without waiting for the compile reload cycle.

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: