diff --git a/magnolia-templating/src/main/java/info/magnolia/templating/freemarker/AreaDirective.java b/magnolia-templating/src/main/java/info/magnolia/templating/freemarker/AreaDirective.java index aa2b4b0..7781474 100644 --- a/magnolia-templating/src/main/java/info/magnolia/templating/freemarker/AreaDirective.java +++ b/magnolia-templating/src/main/java/info/magnolia/templating/freemarker/AreaDirective.java @@ -33,16 +33,17 @@ */ package info.magnolia.templating.freemarker; -import java.io.IOException; -import java.util.Map; - import freemarker.core.Environment; import freemarker.template.TemplateDirectiveBody; import freemarker.template.TemplateModel; import freemarker.template.TemplateModelException; +import freemarker.template.TemplateNumberModel; import info.magnolia.rendering.template.AreaDefinition; import info.magnolia.templating.elements.AreaElement; +import java.io.IOException; +import java.util.Map; + /** * A freemarker directive for rendering an area. */ @@ -62,6 +63,7 @@ public class AreaDirective extends AbstractDirective { String description = string(params, "description", null); Boolean editable = bool(params, "editable", (Boolean) null); Boolean createAreaNode = bool(params, "createAreaNode", (Boolean) null); + Integer maxComponents = integer(params, "maxComponents", null); Map contextAttributes = (Map) object(params, "contextAttributes"); @@ -74,7 +76,16 @@ public class AreaDirective extends AbstractDirective { templatingElement.setDescription(description); templatingElement.setEditable(editable); templatingElement.setCreateAreaNode(createAreaNode); + templatingElement.setMaxComponents(maxComponents); templatingElement.setContextAttributes(contextAttributes); } + + protected Integer integer(Map params, String key, Integer defaultValue) throws TemplateModelException { + final TemplateNumberModel m = _param(params, key, TemplateNumberModel.class, false); + if (m == null) { + return defaultValue; + } + return m.getAsNumber().intValue(); + } }