Class Template
- java.lang.Object
-
- com.google.auto.value.processor.escapevelocity.Template
-
public class Template extends java.lang.ObjectA template expressed in EscapeVelocity, a subset of the Velocity Template Language (VTL) from Apache. The intent of this implementation is that if a template is accepted and successfully produces output, that output will be identical to what Velocity would have produced for the same template and input variables.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTemplate.ResourceOpenerUsed to resolve references to resources in the template, through#parsedirectives.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringevaluate(java.util.Map<java.lang.String,?> vars)Evaluate the given template with the given initial set of variables.static TemplateparseFrom(java.io.Reader reader)Parses a VTL template from the givenReader.static TemplateparseFrom(java.lang.String resourceName, Template.ResourceOpener resourceOpener)Parse a VTL template of the given name using the givenResourceOpener.
-
-
-
Field Detail
-
root
private final Node root
-
-
Constructor Detail
-
Template
Template(Node root)
-
-
Method Detail
-
parseFrom
public static Template parseFrom(java.io.Reader reader) throws java.io.IOException
Parses a VTL template from the givenReader. The given Reader will be closed on return from this method.- Throws:
java.io.IOException
-
parseFrom
public static Template parseFrom(java.lang.String resourceName, Template.ResourceOpener resourceOpener) throws java.io.IOException
Parse a VTL template of the given name using the givenResourceOpener.- Parameters:
resourceName- name of the resource. May be null.resourceOpener- used to open included files for#parsedirectives in the template.- Throws:
java.io.IOException
-
evaluate
public java.lang.String evaluate(java.util.Map<java.lang.String,?> vars)
Evaluate the given template with the given initial set of variables.- Parameters:
vars- a map where the keys are variable names and the values are the corresponding variable values. For example, if"x"maps to 23, then$xin the template will expand to 23.- Returns:
- the string result of evaluating the template.
-
-