|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.mustache.Template
public class Template
Represents a compiled template. Templates are executed with a context to generate
output. The context can be any tree of objects. Variables are resolved against the context.
Given a name 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.
| Method Summary | |
|---|---|
java.lang.String |
execute(java.lang.Object context)
Executes this template with the given context, returning the results as a string. |
void |
execute(java.lang.Object context,
java.io.Writer out)
Executes this template with the given context, writing the results to the supplied writer. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public java.lang.String execute(java.lang.Object context)
throws MustacheException
MustacheException - if an error occurs while executing or writing the template.
public void execute(java.lang.Object context,
java.io.Writer out)
throws MustacheException
MustacheException - if an error occurs while executing or writing the template.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||