Package org.craftercms.engine.freemarker
Class ExecuteControllerDirective
- java.lang.Object
-
- org.craftercms.engine.freemarker.ExecuteControllerDirective
-
- All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel,freemarker.template.TemplateModel
public class ExecuteControllerDirective extends Object implements freemarker.template.TemplateDirectiveModel
Freemarker directive that allows to execute scripts/controllers from inside Freemarker templates. The directive receives a single parameter that is that path of the controller in the site.- Author:
- avasquez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExecuteControllerDirective.EnvironmentGroovyBeanWrapper
-
Field Summary
Fields Modifier and Type Field Description static StringPATH_PARAM_NAMEprotected javax.servlet.ServletContextservletContext
-
Constructor Summary
Constructors Constructor Description ExecuteControllerDirective()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>createScriptVariables(freemarker.core.Environment env)voidexecute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body)protected voidexecuteController(String path, freemarker.core.Environment env)protected voidexecuteController(Script script, Map<String,Object> variables, freemarker.core.Environment env)protected SiteItemgetContentModel(freemarker.core.Environment env)protected StringgetPath(freemarker.template.TemplateModel pathParam, freemarker.core.Environment env)protected ObjectgetTemplateModel(freemarker.core.Environment env)voidsetServletContext(javax.servlet.ServletContext servletContext)
-
-
-
Field Detail
-
PATH_PARAM_NAME
public static final String PATH_PARAM_NAME
- See Also:
- Constant Field Values
-
servletContext
protected javax.servlet.ServletContext servletContext
-
-
Method Detail
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException- Specified by:
executein interfacefreemarker.template.TemplateDirectiveModel- Throws:
freemarker.template.TemplateExceptionIOException
-
executeController
protected void executeController(String path, freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
executeController
protected void executeController(Script script, Map<String,Object> variables, freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
createScriptVariables
protected Map<String,Object> createScriptVariables(freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
getPath
protected String getPath(freemarker.template.TemplateModel pathParam, freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
getContentModel
protected SiteItem getContentModel(freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
getTemplateModel
protected Object getTemplateModel(freemarker.core.Environment env) throws freemarker.template.TemplateException
- Throws:
freemarker.template.TemplateException
-
-