public class FreeMarkerProcessor extends BaseProcessor implements TemplateProcessor, TemplateValueConverter
Service to process FreeMarker template files loaded from various sources including the classpath, repository and directly from a String.
The template is processed against a data model generally consisting of a map of named objects. FreeMarker can natively handle any POJO objects using standard bean notation syntax. It has support for walking List objects. A 'standard' data model helper is provided to help generate an object model containing well known objects such as the Company Home, User Home and current User nodes. It also provides helpful util classes to process Date objects and repository specific custom methods.
extension, name, processorExtensions, scriptService, services, templateService
Constructor and Description |
---|
FreeMarkerProcessor() |
Modifier and Type | Method and Description |
---|---|
Object |
convertValue(Object value,
TemplateImageResolver imageResolver)
Converts a Java object (e.g.
|
protected freemarker.template.Configuration |
getConfig()
Get the FreeMarker configuration for this instance
|
protected freemarker.template.Configuration |
getStringConfig(String path,
String template)
FreeMarker configuration for loading the specified template directly from a String
|
void |
process(String template,
Object model,
Writer out)
Process a template against the supplied data model and write to the out.
|
void |
process(String template,
Object model,
Writer out,
Locale locale)
Process a template in the given locale against the supplied data model and write to the out.
|
void |
processString(String template,
Object model,
Writer out)
Process a string template against the supplied data model and write to the out.
|
void |
setDefaultEncoding(String defaultEncoding)
Set the default template encoding
|
void |
setLocalizedLookup(boolean localizedLookup)
Enable or disable Freemarker's localized lookup feature
|
getExtension, getName, getProcessorExtensions, register, registerProcessorExtension, setExtension, setName, setScriptService, setServiceRegistry, setTemplateService
public void setDefaultEncoding(String defaultEncoding)
defaultEncoding
- the default encodingpublic void setLocalizedLookup(boolean localizedLookup)
protected freemarker.template.Configuration getConfig()
protected freemarker.template.Configuration getStringConfig(String path, String template)
path
- Pseudo Path to the templatetemplate
- Template contentpublic void process(String template, Object model, Writer out)
TemplateProcessor
process
in interface TemplateProcessor
template
- Template name/pathmodel
- Object model to process template againstout
- Writer object to send output tooTemplateProcessor.process(java.lang.String, java.lang.Object, java.io.Writer)
public void process(String template, Object model, Writer out, Locale locale)
TemplateProcessor
process
in interface TemplateProcessor
template
- Template name/pathmodel
- Object model to process template againstout
- Writer object to send output toolocale
- The Locale to process the template inTemplateProcessor.process(java.lang.String, java.lang.Object, java.io.Writer, java.util.Locale)
public void processString(String template, Object model, Writer out)
TemplateProcessor
processString
in interface TemplateProcessor
template
- Template stringmodel
- Object model to process template againstout
- Writer object to send output tooTemplateProcessor.processString(java.lang.String, java.lang.Object, java.io.Writer)
public Object convertValue(Object value, TemplateImageResolver imageResolver)
TemplateValueConverter
convertValue
in interface TemplateValueConverter
value
- the Java object to convertimageResolver
- the image resolverCopyright © 2005–2017 Alfresco Software. All rights reserved.