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.elements;
35
36 import info.magnolia.cms.beans.config.ServerConfiguration;
37 import info.magnolia.context.WebContext;
38 import info.magnolia.objectfactory.Components;
39 import info.magnolia.rendering.context.RenderingContext;
40 import info.magnolia.rendering.engine.RenderException;
41 import info.magnolia.rendering.template.TemplateDefinition;
42 import info.magnolia.templating.module.TemplatingModule;
43
44 import java.io.IOException;
45
46 import javax.inject.Inject;
47 import javax.inject.Provider;
48 import javax.jcr.Node;
49
50
51
52
53 public class PageElement extends AbstractContentTemplatingElement {
54
55 public static final String CMS_PAGE_TAG = "cms:page";
56
57 @Inject
58 public PageElement(ServerConfiguration server, RenderingContext renderingContext, Provider<TemplatingModule> templatingModuleProvider, WebContext webContext) {
59 super(server, renderingContext, templatingModuleProvider, webContext);
60 }
61
62
63
64
65 @Deprecated
66 public PageElement(ServerConfiguration server, RenderingContext renderingContext) {
67 this(server, renderingContext, () -> Components.getComponent(TemplatingModule.class), Components.getComponent(WebContext.class));
68 }
69
70 @Override
71 public void begin(Appendable out) throws IOException, RenderException {
72 if (!renderComments()) {
73 return;
74 }
75
76 Node content = getPassedContent();
77 if (content == null) {
78 content = currentContent();
79 }
80 setContent(content);
81
82 setTemplateDefinition(getRequiredTemplateDefinition());
83
84 MarkupHelper helper = new MarkupHelper(out);
85 helper.openComment(CMS_PAGE_TAG);
86 setPageEditorAttributes(helper, "page");
87 helper.append(" -->\n");
88 helper.closeComment(CMS_PAGE_TAG);
89
90 }
91
92 @Override
93 public void end(Appendable out) throws IOException, RenderException {
94 if (!renderComments()) {
95 }
96 }
97
98 private TemplateDefinition getRequiredTemplateDefinition() {
99 return (TemplateDefinition) getRenderingContext().getRenderableDefinition();
100 }
101 }