@AlfrescoPublicApi
public interface TemplateService
Provides an interface to services for executing template engine against a template file and data model.
The service provides a configured list of available template engines. The template file can either be in the repository (passed as NodeRef string) or on the classpath. Also a template can be passed directly as a String using the processTemplateString() methods.
The data model is specified to the template engine. The FreeMarker template engine is used by default.
| Modifier and Type | Field and Description |
|---|---|
static String |
KEY_COMPANY_HOME |
static String |
KEY_DATE |
static String |
KEY_IMAGE_RESOLVER
Keys for default model values
|
static String |
KEY_PERSON |
static String |
KEY_PRODUCT_NAME |
static String |
KEY_SHARE_URL |
static String |
KEY_TEMPLATE |
static String |
KEY_USER_HOME |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person,
org.alfresco.service.cmr.repository.NodeRef companyHome,
org.alfresco.service.cmr.repository.NodeRef userHome,
org.alfresco.service.cmr.repository.NodeRef template,
TemplateImageResolver imageResolver)
Helper method to build a default model
|
TemplateProcessor |
getTemplateProcessor(String engine)
Return a TemplateProcessor instance for the specified engine name.
|
String |
processTemplate(String template,
Object model)
Process a template against the upplied data model and return the result as
a string.
|
void |
processTemplate(String template,
Object model,
Writer out)
Process a template against the supplied data model and write to the out.
|
String |
processTemplate(String engine,
String template,
Object model)
Process a template against the supplied data model and write to the out.
|
String |
processTemplate(String engine,
String templateRef,
Object model,
Locale locale)
Process a template using the supplied locale against the supplied data model and write to the out.
|
void |
processTemplate(String engine,
String template,
Object model,
Writer out)
Process a template against the supplied data model and write to the out.
|
String |
processTemplateString(String engine,
String template,
Object model)
Process a given template, provided as a string, against the supplied data model and return the result as a String
|
void |
processTemplateString(String engine,
String template,
Object model,
Writer out)
Process a given template, provided as a string, against the supplied data model and report the
result back in the provided writer.
|
void |
registerTemplateProcessor(TemplateProcessor templateProcessor)
Registers a new template processor with the template service
|
static final String KEY_IMAGE_RESOLVER
static final String KEY_COMPANY_HOME
static final String KEY_USER_HOME
static final String KEY_PERSON
static final String KEY_TEMPLATE
static final String KEY_DATE
static final String KEY_SHARE_URL
static final String KEY_PRODUCT_NAME
@Auditable(parameters={"template","model"})
String processTemplate(String template,
Object model)
throws TemplateException
template - Template (qualified classpath name or noderef)model - Object model to process template againstTemplateException@Auditable(parameters={"template","model","out"})
void processTemplate(String template,
Object model,
Writer out)
throws TemplateException
template - Template (qualified classpath name or noderef)model - Object model to process template againstout - Writer object to send output tooTemplateException@Auditable(parameters={"engine","template","model"})
String processTemplate(String engine,
String template,
Object model)
throws TemplateException
engine - Name of the template engine to usetemplate - Template (qualified classpath name or noderef)model - Object model to process template againstTemplateException@Auditable(parameters={"engine","template","model","out"})
void processTemplate(String engine,
String template,
Object model,
Writer out)
throws TemplateException
engine - Name of the template engine to usetemplate - Template (qualified classpath name or noderef)model - Object model to process template againstout - Writer object to send output tooTemplateException@Auditable(parameters={"engine","template","model","out","locale"})
String processTemplate(String engine,
String templateRef,
Object model,
Locale locale)
throws TemplateException
engine - Name of the template engine to usetemplateRef - Template ref (qualified classpath name or noderef)model - Object model to process template againstlocale - Locale to process the template asTemplateException@Auditable(parameters={"engine","template","model"})
String processTemplateString(String engine,
String template,
Object model)
throws TemplateException
engine - Name of the template engine to usetemplate - Template stringmodel - Object model to process template againstTemplateException@Auditable(parameters={"engine","template","model","out"})
void processTemplateString(String engine,
String template,
Object model,
Writer out)
throws TemplateException
engine - Name of the template engine to usetemplate - Template stringmodel - Object model to process template againstout - Writer object to send output tooTemplateException@Auditable(parameters="engine") TemplateProcessor getTemplateProcessor(String engine)
engine - Name of the template engine to get or null for default@Auditable(parameters="templateProcessor") void registerTemplateProcessor(TemplateProcessor templateProcessor)
templateProcessor - the template processor to register@Auditable(parameters={"person","companyHome","userHome","template","imageResolver"})
Map<String,Object> buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person,
org.alfresco.service.cmr.repository.NodeRef companyHome,
org.alfresco.service.cmr.repository.NodeRef userHome,
org.alfresco.service.cmr.repository.NodeRef template,
TemplateImageResolver imageResolver)
person - the person node referencecompanyHome - the company home node refereenceuserHome - the user home node referencetemplate - the node ref for the template (optional)imageResolver - the image resolver (optional)Copyright © 2005–2018 Alfresco Software. All rights reserved.