C
- the templating element the directive is operating onpublic abstract class AbstractDirective<C extends TemplatingElement> extends Object implements freemarker.template.TemplateDirectiveModel
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_ATTRIBUTE |
static String |
PATH_ATTRIBUTE |
static String |
UUID_ATTRIBUTE |
static String |
WORKSPACE_ATTRIBUTE |
Constructor and Description |
---|
AbstractDirective() |
Modifier and Type | Method and Description |
---|---|
protected <MT extends freemarker.template.TemplateModel> |
_param(Map<String,freemarker.template.TemplateModel> params,
String key,
Class<MT> type,
boolean isMandatory) |
protected Boolean |
bool(Map<String,freemarker.template.TemplateModel> params,
String key,
Boolean defaultValue) |
protected void |
checkBody(freemarker.template.TemplateDirectiveBody body,
boolean needsBody)
Utility method for directives who need to ensure they're used with or without a body.
|
protected info.magnolia.cms.core.Content |
content(Map<String,freemarker.template.TemplateModel> params,
String key,
info.magnolia.cms.core.Content defaultValue)
Deprecated.
|
protected C |
createTemplatingElement() |
protected void |
doBody(freemarker.core.Environment env,
freemarker.template.TemplateDirectiveBody body) |
void |
execute(freemarker.core.Environment env,
Map params,
freemarker.template.TemplateModel[] loopVars,
freemarker.template.TemplateDirectiveBody body) |
protected Class<C> |
getTemplatingElementClass() |
protected void |
initContentElement(Map<String,freemarker.template.TemplateModel> params,
AbstractContentTemplatingElement component)
Init attributes common to all
AbstractContentTemplatingElement . |
protected Integer |
integer(Map<String,freemarker.template.TemplateModel> params,
String key,
Integer defaultValue) |
protected boolean |
mandatoryBool(Map<String,freemarker.template.TemplateModel> params,
String key) |
protected info.magnolia.cms.core.Content |
mandatoryContent(Map<String,freemarker.template.TemplateModel> params,
String key)
Deprecated.
|
protected Object |
mandatoryObject(Map<String,freemarker.template.TemplateModel> params,
String key) |
protected String |
mandatoryString(Map<String,freemarker.template.TemplateModel> params,
String key) |
protected List<String> |
mandatoryStringList(Map<String,freemarker.template.TemplateModel> params,
String key) |
protected javax.jcr.Node |
node(Map<String,freemarker.template.TemplateModel> params,
String key,
javax.jcr.Node defaultValue) |
protected Object |
object(Map<String,freemarker.template.TemplateModel> params,
String key) |
protected abstract void |
prepareTemplatingElement(C templatingElement,
freemarker.core.Environment env,
Map<String,freemarker.template.TemplateModel> params,
freemarker.template.TemplateModel[] loopVars,
freemarker.template.TemplateDirectiveBody body)
Implementations of this method should prepare the TemplatingElement with the known parameters.
|
protected String |
string(Map<String,freemarker.template.TemplateModel> params,
String key,
String defaultValue) |
public static final String PATH_ATTRIBUTE
public static final String UUID_ATTRIBUTE
public static final String WORKSPACE_ATTRIBUTE
public static final String CONTENT_ATTRIBUTE
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException
execute
in interface freemarker.template.TemplateDirectiveModel
freemarker.template.TemplateException
IOException
protected C createTemplatingElement()
protected abstract void prepareTemplatingElement(C templatingElement, freemarker.core.Environment env, Map<String,freemarker.template.TemplateModel> params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateModelException, IOException
execute(freemarker.core.Environment, java.util.Map, freemarker.template.TemplateModel[], freemarker.template.TemplateDirectiveBody)
will throw a TemplateModelException if there are leftover parameters.
note: The current FreeMarker implementation passes a "new" Map which we can safely manipulate.
is thrown away after the execution of the directive. When no parameters are passed, the Map is readonly, but it
is otherwise a regular HashMap which has been instantiated shortly before the execution of the directive. However, since
this behavior is not mandated by their API, nor documented (at the time of writing, with FreeMarker 2.3.16), we
should exert caution. Unit tests hopefully cover this, so we'll be safe when updating to newer FreeMarker versions.freemarker.template.TemplateModelException
IOException
protected void doBody(freemarker.core.Environment env, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException
freemarker.template.TemplateException
IOException
protected void checkBody(freemarker.template.TemplateDirectiveBody body, boolean needsBody) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected String mandatoryString(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected String string(Map<String,freemarker.template.TemplateModel> params, String key, String defaultValue) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected boolean mandatoryBool(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected Boolean bool(Map<String,freemarker.template.TemplateModel> params, String key, Boolean defaultValue) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected Integer integer(Map<String,freemarker.template.TemplateModel> params, String key, Integer defaultValue) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
@Deprecated protected info.magnolia.cms.core.Content mandatoryContent(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
@Deprecated protected info.magnolia.cms.core.Content content(Map<String,freemarker.template.TemplateModel> params, String key, info.magnolia.cms.core.Content defaultValue) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected javax.jcr.Node node(Map<String,freemarker.template.TemplateModel> params, String key, javax.jcr.Node defaultValue) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected Object object(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected Object mandatoryObject(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected List<String> mandatoryStringList(Map<String,freemarker.template.TemplateModel> params, String key) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected <MT extends freemarker.template.TemplateModel> MT _param(Map<String,freemarker.template.TemplateModel> params, String key, Class<MT> type, boolean isMandatory) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected void initContentElement(Map<String,freemarker.template.TemplateModel> params, AbstractContentTemplatingElement component) throws freemarker.template.TemplateModelException
AbstractContentTemplatingElement
.freemarker.template.TemplateModelException
Copyright © 2003–2016 Magnolia International Ltd.. All rights reserved.