Package io.jstach.jstachio.context
Models traditionally in web applications and template engines in general are Map based. JStachio prefers stronger typing than that however there are many scenarios where Map approach might be better for legacy reasons or because of variables that need to be added after the model has been created. An example is web applications where request based attributes may need to be available to the model such as CSRF token.
A special JStachio allows you to pass in a context that will be bound with "@context" as the variable name.
On the otherhand if the desire is to just render Map as a root object and are willing
to accept the lack of type checking one can make an annotated
JStache
model that extends
ObjectContext
.
None of this behavior in this package is available to generated code that is
JStacheType.STACHE
. By default
JStacheType.JSTACHIO
templates are context aware. To disable
use JStacheFlags.Flag.CONTEXT_SUPPORT_DISABLE
.
- API Note
- Much of this package is an experimental extension of JStachio and while we try to limit public API additions the proper use cases and design are still ongoing.
-
ClassDescriptionA special JStachio that can render models with a loose typed context object bound to "@context".This interface serves three puproses: A way to represent the current context stack (see
ContextNode.parent()
) Allow you to simulate JSON/Javscript object node like trees without being coupled to a particularly JSON lib.A marker interface to signify something is context aware.A context aware template.Extend this class to makeJStache
model act like JSON object or a java.util.Map.