Package liqp
Class Template
java.lang.Object
liqp.Template
The main class of this library. Use one of its static
parse(...) to get a hold of a
reference.
Also see: https://github.com/Shopify/liquid-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSometimes the custom insertions needs to return some extra-data, that is not rendarable. -
Method Summary
Modifier and TypeMethodDescriptionerrors()org.antlr.v4.runtime.tree.ParseTreeReturns the root of the parse tree of the parsed input.render()Renders the template.Renders the template.Renders the template.render(Map<String, Object> variables, ExecutorService executorService, boolean shutdown) render(Inspectable object) renderObject(Object obj) Render the template with given object, treating it same way asInspectableinstance.renderToObject(String jsonMap) renderToObject(Map<String, Object> variables) Renders the template.renderToObject(Inspectable object) renderToObjectUnguarded(Map<String, Object> variables) Renders the template without guards provided by protection settings.renderToObjectUnguarded(Map<String, Object> variables, TemplateContext parent, boolean doClearThreadLocal) renderUnguarded(Map<String, Object> variables) Renders the template without guards provided by protection settings.renderUnguarded(Map<String, Object> variables, TemplateContext parent, boolean doClearThreadLocal) renderUnguarded(TemplateContext parent) Renders the template using parent contextReturns a string representation of the parse tree of the parsed input source.
-
Method Details
-
getParseTree
public org.antlr.v4.runtime.tree.ParseTree getParseTree()Returns the root of the parse tree of the parsed input.- Returns:
- the root of the parse tree of the parsed input.
-
withContextHolder
-
errors
-
render
Renders the template.- Parameters:
jsonMap- a JSON-map denoting the (possibly nested) variables that can be used in this Template.- Returns:
- a string denoting the rendered template.
-
renderToObject
-
render
-
renderToObject
-
render
-
renderToObject
-
renderObject
Render the template with given object, treating it same way asInspectableinstance. -
render
Renders the template.- Parameters:
key- a keyvalue- the value belonging to the keykeyValues- an array denoting key-value pairs where the uneven numbers (even indexes) should be Strings. If the length of this array is uneven, the last key (without the value) gets `null` attached to it. Note that a call to this method with a single String as parameter, will be handled by `render(String jsonMap)` instead.- Returns:
- a string denoting the rendered template.
-
render
-
render
Renders the template.- Parameters:
variables- a Map denoting the (possibly nested) variables that can be used in this Template.- Returns:
- a string denoting the rendered template.
-
renderToObject
Renders the template. The returned type is unspecified (as it may be controlled by a customRenderTransformer), however callingObject.toString()on that object is guaranteed to be equivalent to callingrender(Map).- Parameters:
variables- a Map denoting the (possibly nested) variables that can be used in this Template.- Returns:
- an object denoting the rendered template.
-
render
public String render(Map<String, Object> variables, ExecutorService executorService, boolean shutdown) -
renderUnguarded
Renders the template without guards provided by protection settings. This method has about 300x times better performance than plain render.- Parameters:
variables- a Map denoting the (possibly nested) variables that can be used in this Template.- Returns:
- a string denoting the rendered template.
-
renderToObjectUnguarded
Renders the template without guards provided by protection settings. The returned type is unspecified (as it may be controlled by a customRenderTransformer), however callingObject.toString()on that object is guaranteed to be equivalent to callingrenderToObjectUnguarded(Map).- Parameters:
variables- a Map denoting the (possibly nested) variables that can be used in this Template.- Returns:
- an object denoting the rendered template.
-
renderUnguarded
public String renderUnguarded(Map<String, Object> variables, TemplateContext parent, boolean doClearThreadLocal) -
renderToObjectUnguarded
public Object renderToObjectUnguarded(Map<String, Object> variables, TemplateContext parent, boolean doClearThreadLocal) -
renderUnguarded
Renders the template using parent context- Parameters:
parent- The parent context.- Returns:
- a string denoting the rendered template.
-
toStringTree
Returns a string representation of the parse tree of the parsed input source.- Returns:
- a string representation of the parse tree of the parsed input source.
-