--- a/src/pyams_default_theme/viewlet/tag/__init__.py Fri Nov 23 15:25:34 2018 +0100
+++ b/src/pyams_default_theme/viewlet/tag/__init__.py Fri Nov 23 15:26:01 2018 +0100
@@ -10,16 +10,18 @@
# FOR A PARTICULAR PURPOSE.
#
-
__docformat__ = 'restructuredtext'
from pyramid.decorator import reify
+from zope.contentprovider.interfaces import IContentProvider
from zope.interface import Interface
from pyams_content.component.theme import ITagsInfo, ITagsManager
from pyams_sequence.reference import get_reference_target
from pyams_skin.layer import IPyAMSLayer, IPyAMSUserLayer
from pyams_template.template import template_config
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
+from pyams_utils.interfaces.tales import ITALESExtension
from pyams_viewlet.viewlet import ViewContentProvider, contentprovider_config
@@ -49,3 +51,19 @@
def tags(self):
tags = self.tags_info.tags or ()
yield from sorted(tags, key=lambda x: (x.order or 999, x.alt or x.label))
+
+
+@adapter_config(name='tags', context=(Interface, Interface, Interface), provides=ITALESExtension)
+class TagsTalesExtension(ContextRequestViewAdapter):
+ """tales:tags(context) TALES extension"""
+
+ def render(self, context=None):
+ if context is None:
+ context = self.context
+ provider = self.request.registry.queryMultiAdapter((context, self.request, self.view), IContentProvider,
+ name='pyams.tags')
+ if provider is not None:
+ provider.update()
+ return provider.render()
+ else:
+ return ''