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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringstatic final Stringstatic final StringDeprecated.protected org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> protected SiteItemScriptResolverprotected jakarta.servlet.ServletContextprotected SiteItemServiceprotected Stringprotected Stringprotected StringFields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
ConstructorsConstructorDescriptionRenderComponentDirective(jakarta.servlet.ServletContext servletContext, SiteItemService siteItemService, org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory, String templateXPathQuery, String templateNamePrefix, String templateNameSuffix, String includeElementName, String componentElementName, SiteItemScriptResolver scriptResolver) -
Method Summary
Modifier and TypeMethodDescriptioncreateScriptVariables(SiteItem component, Map<String, Object> templateModel, Map<String, Object> additionalModel) voidexecute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) protected voidexecuteScript(Script script, Map<String, Object> scriptVariables, freemarker.core.Environment env) executeScripts(SiteItem component, Map<String, Object> additionalModel, freemarker.core.Environment env) protected SiteItemgetComponent(String componentPath, freemarker.core.Environment env) protected SiteItemgetComponentFromNode(freemarker.template.TemplateModel parentParam, freemarker.template.TemplateModel componentParam, freemarker.core.Environment env) protected SiteItemgetComponentFromPath(freemarker.template.TemplateModel componentPathParam, freemarker.core.Environment env) protected StringgetComponentTemplateName(SiteItem component, freemarker.core.Environment env) protected freemarker.template.SimpleHashgetFullModel(SiteItem component, Map<String, Object> templateModel, Map<String, Object> additionalModel) protected freemarker.template.TemplategetTemplate(SiteItem component, freemarker.core.Environment env) protected voidprocessComponentTemplate(freemarker.template.Template template, freemarker.template.SimpleHash model, Writer output, freemarker.core.Environment env) protected <T> Tunwrap(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 jakarta.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(jakarta.servlet.ServletContext servletContext, SiteItemService siteItemService, org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory, String templateXPathQuery, String templateNamePrefix, String templateNameSuffix, String includeElementName, String componentElementName, SiteItemScriptResolver scriptResolver)
-
-
Method Details
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException - Specified by:
executein 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
-