Package org.craftercms.engine.freemarker
Class RenderComponentDirective
java.lang.Object
org.craftercms.engine.freemarker.RenderComponentDirective
- All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel
,freemarker.template.TemplateModel
public class RenderComponentDirective
extends Object
implements freemarker.template.TemplateDirectiveModel
Custom directive to render a component by processing the template defined in the component element's template name
sub-element.
- Author:
- Alfonso Vásquez
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
protected String
protected String
static final String
static final String
Deprecated.protected org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash>
protected SiteItemScriptResolver
protected javax.servlet.ServletContext
protected SiteItemService
protected String
protected String
protected String
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateScriptVariables
(SiteItem component, Map<String, Object> templateModel, Map<String, Object> additionalModel) void
execute
(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) protected void
executeScript
(Script script, Map<String, Object> scriptVariables, freemarker.core.Environment env) executeScripts
(SiteItem component, Map<String, Object> additionalModel, freemarker.core.Environment env) protected SiteItem
getComponent
(String componentPath, freemarker.core.Environment env) protected SiteItem
getComponentFromNode
(freemarker.template.TemplateModel parentParam, freemarker.template.TemplateModel componentParam, freemarker.core.Environment env) protected SiteItem
getComponentFromPath
(freemarker.template.TemplateModel componentPathParam, freemarker.core.Environment env) protected String
getComponentTemplateName
(SiteItem component, freemarker.core.Environment env) protected freemarker.template.SimpleHash
getFullModel
(SiteItem component, Map<String, Object> templateModel, Map<String, Object> additionalModel) protected freemarker.template.Template
getTemplate
(SiteItem component, freemarker.core.Environment env) protected void
processComponentTemplate
(freemarker.template.Template template, freemarker.template.SimpleHash model, Writer output, freemarker.core.Environment env) void
setComponentElementName
(String componentElementName) void
setIncludeElementName
(String includeElementName) void
setModelFactory
(org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory) void
setScriptResolver
(SiteItemScriptResolver scriptResolver) void
setServletContext
(javax.servlet.ServletContext servletContext) void
setSiteItemService
(SiteItemService siteItemService) void
setTemplateNamePrefix
(String templateNamePrefix) void
setTemplateNameSuffix
(String templateNameSuffix) void
setTemplateXPathQuery
(String templateXPathQuery) protected <T> T
unwrap
(String name, freemarker.template.TemplateModel value, Class<T> expectedClass, freemarker.core.Environment env)
-
Field Details
-
KEY_MODEL
Deprecated.- See Also:
-
KEY_CONTENT_MODEL
- See Also:
-
COMPONENT_PARENT_PARAM_NAME
- See Also:
-
COMPONENT_PARAM_NAME
- See Also:
-
COMPONENT_PATH_PARAM_NAME
- See Also:
-
ADDITIONAL_MODEL_PARAM_NAME
- See Also:
-
servletContext
protected javax.servlet.ServletContext servletContext -
siteItemService
-
modelFactory
protected org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory -
templateXPathQuery
-
templateNamePrefix
-
templateNameSuffix
-
includeElementName
-
componentElementName
-
scriptResolver
-
-
Constructor Details
-
RenderComponentDirective
public RenderComponentDirective()
-
-
Method Details
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext) -
setSiteItemService
-
setModelFactory
public void setModelFactory(org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory) -
setTemplateXPathQuery
-
setTemplateNamePrefix
-
setTemplateNameSuffix
-
setIncludeElementName
-
setComponentElementName
-
setScriptResolver
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException - Specified by:
execute
in interfacefreemarker.template.TemplateDirectiveModel
- Throws:
freemarker.template.TemplateException
-
getComponentFromNode
protected SiteItem getComponentFromNode(freemarker.template.TemplateModel parentParam, freemarker.template.TemplateModel componentParam, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
getComponentFromPath
protected SiteItem getComponentFromPath(freemarker.template.TemplateModel componentPathParam, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
getComponent
protected SiteItem getComponent(String componentPath, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
executeScripts
protected Map<String,Object> executeScripts(SiteItem component, Map<String, Object> additionalModel, freemarker.core.Environment env) throws freemarker.template.TemplateException- Throws:
freemarker.template.TemplateException
-
createScriptVariables
-
executeScript
protected void executeScript(Script script, Map<String, Object> scriptVariables, freemarker.core.Environment env) throws freemarker.template.TemplateException- Throws:
freemarker.template.TemplateException
-
getTemplate
protected freemarker.template.Template getTemplate(SiteItem component, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
getComponentTemplateName
protected String getComponentTemplateName(SiteItem component, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
getFullModel
protected freemarker.template.SimpleHash getFullModel(SiteItem component, Map<String, Object> templateModel, Map<String, throws freemarker.template.TemplateExceptionObject> additionalModel) - Throws:
freemarker.template.TemplateException
-
processComponentTemplate
protected void processComponentTemplate(freemarker.template.Template template, freemarker.template.SimpleHash model, Writer output, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-
unwrap
protected <T> T unwrap(String name, freemarker.template.TemplateModel value, Class<T> expectedClass, freemarker.core.Environment env) throws freemarker.template.TemplateException - Throws:
freemarker.template.TemplateException
-