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 class
ExecuteControllerDirective.EnvironmentGroovyBeanWrapper
-
Field Summary
Fields Modifier and Type Field Description static String
PATH_PARAM_NAME
protected javax.servlet.ServletContext
servletContext
-
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)
void
execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body)
protected void
executeController(String path, freemarker.core.Environment env)
protected void
executeController(Script script, Map<String,Object> variables, freemarker.core.Environment env)
protected SiteItem
getContentModel(freemarker.core.Environment env)
protected String
getPath(freemarker.template.TemplateModel pathParam, freemarker.core.Environment env)
protected Object
getTemplateModel(freemarker.core.Environment env)
void
setServletContext(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:
execute
in interfacefreemarker.template.TemplateDirectiveModel
- Throws:
freemarker.template.TemplateException
IOException
-
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
-
-