com.samskivert.mustache
Class Template

java.lang.Object
  extended by com.samskivert.mustache.Template

public class Template
extends java.lang.Object

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):

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

execute

public java.lang.String execute(java.lang.Object context)
                         throws MustacheException
Executes this template with the given context, returning the results as a string.

Throws:
MustacheException - if an error occurs while executing or writing the template.

execute

public void execute(java.lang.Object context,
                    java.io.Writer out)
             throws MustacheException
Executes this template with the given context, writing the results to the supplied writer.

Throws:
MustacheException - if an error occurs while executing or writing the template.


Copyright © 2011. All Rights Reserved.