public class Template extends Object
foo
, the following mechanisms are supported for resolving its value
(and are sought in this order):
this
the context object itself will be
returned. This is useful when iterating over lists.
Map
, Map.get(java.lang.Object)
will be called with the string foo
as the key.
foo
in the supplied object (with non-void return value).
getFoo
in the supplied object (with non-void return value).
foo
in the supplied object.
The field type, method return type, or map value type should correspond to the desired
behavior if the resolved name corresponds to a section. Boolean
is used for showing or
hiding sections without binding a sub-context. Arrays, Iterator
and Iterable
implementations are used for sections that repeat, with the context bound to the elements of the
array, iterator or iterable. Lambdas are current unsupported, though they would be easy enough
to add if desire exists. See the Mustache
documentation for more details on section behavior.
Modifier and Type | Class and Description |
---|---|
class |
Template.Fragment
Encapsulates a fragment of a template that is passed to a lambda.
|
Modifier and Type | Field and Description |
---|---|
static Object |
NO_FETCHER_FOUND
A sentinel object that can be returned by a
Mustache.Collector to indicate that a
variable does not exist in a particular context. |
Modifier and Type | Method and Description |
---|---|
String |
execute(Object context)
Executes this template with the given context, returning the results as a string.
|
void |
execute(Object context,
Object parentContext,
Writer out)
Executes this template with the supplied context and parent context, writing the results to
the supplied writer.
|
void |
execute(Object context,
Writer out)
Executes this template with the given context, writing the results to the supplied writer.
|
public static final Object NO_FETCHER_FOUND
Mustache.Collector
to indicate that a
variable does not exist in a particular context.public String execute(Object context) throws MustacheException
MustacheException
- if an error occurs while executing or writing the template.public void execute(Object context, Writer out) throws MustacheException
MustacheException
- if an error occurs while executing or writing the template.public void execute(Object context, Object parentContext, Writer out) throws MustacheException
MustacheException
- if an error occurs while executing or writing the template.Copyright © 2016. All rights reserved.