Updated paragraphs renderer
authorThierry Florac <thierry.florac@onf.fr>
Mon, 10 Sep 2018 12:13:13 +0200
changeset 140 45dd221040a4
parent 139 61ba7f260f3b
child 141 ed88a74f4032
Updated paragraphs renderer
src/pyams_default_theme/component/association/__init__.py
src/pyams_default_theme/component/association/templates/association-remote-content.pt
--- a/src/pyams_default_theme/component/association/__init__.py	Mon Sep 10 12:02:03 2018 +0200
+++ b/src/pyams_default_theme/component/association/__init__.py	Mon Sep 10 12:13:13 2018 +0200
@@ -97,8 +97,12 @@
         self.links = [item for item in IAssociationContainer(self.context).get_visible_items(self.request)
                       if IInternalLink.providedBy(item) and IParagraphContainerTarget.providedBy(item.target)]
 
-    def get_paragraphs(self, target):
+    def get_renderers(self, target):
         container = IParagraphContainer(target, None)
         if container is not None:
             settings = self.settings
-            yield from container.get_visible_paragraphs(None, settings.anchors_only, settings.factories)
+            for renderer in map(lambda x: x.get_renderer(self.request),
+                                container.get_visible_paragraphs(None, settings.anchors_only, settings.factories)):
+                if renderer is not None:
+                    renderer.update()
+                    yield renderer.render()
--- a/src/pyams_default_theme/component/association/templates/association-remote-content.pt	Mon Sep 10 12:02:03 2018 +0200
+++ b/src/pyams_default_theme/component/association/templates/association-remote-content.pt	Mon Sep 10 12:13:13 2018 +0200
@@ -7,10 +7,8 @@
 			<div class="chapo"
 				 tal:define="header i18n:target.header"
 				 tal:condition="settings.display_header">${structure:tales:html(header)}</div>
-			<tal:loop repeat="paragraph view.get_paragraphs(target)">
-				<tal:var define="renderer paragraph.get_renderer(request);
-								 ignore renderer.update() if renderer is not None else None;"
-						 condition="renderer is not None">${structure:renderer.render()}</tal:var>
+			<tal:loop repeat="renderer view.get_renderers(target)">
+				${structure:renderer}
 			</tal:loop>
 		</tal:var>
 	</tal:loop>