1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.templating.freemarker;
35
36 import java.io.IOException;
37 import java.util.Map;
38
39 import freemarker.core.Environment;
40 import freemarker.template.TemplateDirectiveBody;
41 import freemarker.template.TemplateModel;
42 import freemarker.template.TemplateModelException;
43 import info.magnolia.rendering.template.AreaDefinition;
44 import info.magnolia.templating.elements.AreaElement;
45
46
47
48
49
50
51 public class AreaDirective extends AbstractDirective<AreaElement> {
52
53 @Override
54 protected void prepareTemplatingElement(AreaElement templatingElement, Environment env, Map<String, TemplateModel> params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateModelException, IOException {
55
56 initContentElement(params, templatingElement);
57
58 AreaDefinition area = (AreaDefinition) object(params, "area");
59 String name = string(params, "name", null);
60 String availableComponents = string(params, "components", null);
61 String dialog = string(params, "dialog", null);
62 String type = string(params, "type", null);
63 String label = string(params, "label", null);
64 String description = string(params, "description", null);
65 Boolean editable = bool(params, "editable", (Boolean) null);
66
67 Map<String,Object> contextAttributes = (Map<String, Object>) object(params, "contextAttributes");
68
69 templatingElement.setArea(area);
70 templatingElement.setName(name);
71 templatingElement.setAvailableComponents(availableComponents);
72 templatingElement.setDialog(dialog);
73 templatingElement.setType(type);
74 templatingElement.setLabel(label);
75 templatingElement.setDescription(description);
76 templatingElement.setEditable(editable);
77
78 templatingElement.setContextAttributes(contextAttributes);
79 }
80 }