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 Details

    • KEY_MODEL

      @Deprecated public static final String KEY_MODEL
      Deprecated.
      See Also:
    • KEY_CONTENT_MODEL

      public static final String KEY_CONTENT_MODEL
      See Also:
    • COMPONENT_PARENT_PARAM_NAME

      public static final String COMPONENT_PARENT_PARAM_NAME
      See Also:
    • COMPONENT_PARAM_NAME

      public static final String COMPONENT_PARAM_NAME
      See Also:
    • COMPONENT_PATH_PARAM_NAME

      public static final String COMPONENT_PATH_PARAM_NAME
      See Also:
    • ADDITIONAL_MODEL_PARAM_NAME

      public static final String ADDITIONAL_MODEL_PARAM_NAME
      See Also:
    • servletContext

      protected javax.servlet.ServletContext servletContext
    • siteItemService

      protected SiteItemService siteItemService
    • modelFactory

      protected org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory
    • templateXPathQuery

      protected String templateXPathQuery
    • templateNamePrefix

      protected String templateNamePrefix
    • templateNameSuffix

      protected String templateNameSuffix
    • includeElementName

      protected String includeElementName
    • componentElementName

      protected String componentElementName
    • scriptResolver

      protected SiteItemScriptResolver scriptResolver
  • Constructor Details

    • RenderComponentDirective

      public RenderComponentDirective()
  • Method Details

    • setServletContext

      public void setServletContext(javax.servlet.ServletContext servletContext)
    • setSiteItemService

      public void setSiteItemService(SiteItemService siteItemService)
    • setModelFactory

      public void setModelFactory(org.springframework.beans.factory.ObjectFactory<freemarker.template.SimpleHash> modelFactory)
    • setTemplateXPathQuery

      public void setTemplateXPathQuery(String templateXPathQuery)
    • setTemplateNamePrefix

      public void setTemplateNamePrefix(String templateNamePrefix)
    • setTemplateNameSuffix

      public void setTemplateNameSuffix(String templateNameSuffix)
    • setIncludeElementName

      public void setIncludeElementName(String includeElementName)
    • setComponentElementName

      public void setComponentElementName(String componentElementName)
    • setScriptResolver

      public void setScriptResolver(SiteItemScriptResolver scriptResolver)
    • 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 interface freemarker.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

      protected Map<String,Object> createScriptVariables(SiteItem component, Map<String,Object> templateModel, Map<String,Object> additionalModel)
    • 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,Object> additionalModel) throws freemarker.template.TemplateException
      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