public class Template extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Template.ResourceOpener
Used to resolve references to resources in the template, through
#parse directives. |
Modifier and Type | Method and Description |
---|---|
String |
evaluate(Map<String,?> vars)
Evaluate the given template with the given initial set of variables.
|
static Template |
parseFrom(Reader reader)
Parses a VTL template from the given
Reader . |
static Template |
parseFrom(String resourceName,
Template.ResourceOpener resourceOpener)
Parse a VTL template of the given name using the given
ResourceOpener . |
public static Template parseFrom(Reader reader) throws IOException
Reader
. The given Reader will be closed on
return from this method.IOException
public static Template parseFrom(String resourceName, Template.ResourceOpener resourceOpener) throws IOException
ResourceOpener
.resourceName
- name of the resource. May be null.resourceOpener
- used to open included files for #parse
directives in the
template.IOException
public String evaluate(Map<String,?> vars)
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 $x
in the template
will expand to 23.Copyright © 2019. All rights reserved.