public class CarrotEngine
extends java.lang.Object
CarrotEngine is the root of the carrot system. You create an instance of this, make it global or static,
load templates and process them from here.| Constructor and Description |
|---|
CarrotEngine(Configuration config)
Constructs a new
CarrotEngine with the given Configuration. |
| Modifier and Type | Method and Description |
|---|---|
Configuration |
getConfig() |
MapBindings |
getGlobalBindings() |
java.lang.String |
process(java.lang.String templateFile,
Bindings bindings)
Process the template with the given filename, and returns the result as a string.
|
void |
process(java.io.Writer writer,
ResourceName resourceName,
Scope scope)
Process the template with the given filename, writing the results to the given
Writer. |
void |
process(java.io.Writer writer,
java.lang.String templateFile,
Bindings bindings)
Process the template with the given filename, writing the results to the given
Writer. |
public CarrotEngine(Configuration config)
CarrotEngine with the given Configuration.
The configuration is immutable, so you should create it with all of the settings you need first.
config - The Configuration to construct this engine with.public Configuration getConfig()
Configuration. The configuration is mutable, so you are able to modify settings on the value
returned here and they will take effect on the current CarrotEngine.public MapBindings getGlobalBindings()
CarrotEngine.public void process(java.io.Writer writer,
ResourceName resourceName,
Scope scope)
throws CarrotException
Writer.writer - A Writer to write the results of processing the given template to.resourceName - The ResourceName of the template file, which will be located by our configured
ResourceLocator.scope - The Scope we're rendering into.CarrotException - Thrown if any errors occur.public void process(java.io.Writer writer,
java.lang.String templateFile,
@Nullable
Bindings bindings)
throws CarrotException
Writer.writer - A Writer to write the results of processing the given template to.templateFile - The name of the template file, which will be resolved by our configured
ResourceLocator.bindings - A mapping of string to variables that make up the bindings for this template.CarrotException - Thrown if any errors occur.public java.lang.String process(java.lang.String templateFile,
@Nullable
Bindings bindings)
throws CarrotException
templateFile - The name of the template file, which will be resolved by our configured
ResourceLocator.bindings - A mapping of string to variables that make up the bindings for this template.CarrotException - Thrown if any errors occur.