Renderer returning data, with appended default context as dict (#6870)
This commit is contained in:
parent
bf976e8ad9
commit
7d32047694
|
@ -124,6 +124,20 @@ class DictRenderer(Renderer):
|
|||
return context
|
||||
|
||||
|
||||
class DictRendererWithDefault(DictRenderer):
|
||||
"""
|
||||
Same as DictRender but each dict item contains data under "data" key and
|
||||
the config defaults unde "default" key
|
||||
"""
|
||||
|
||||
def get_sources(self, context):
|
||||
for source in self.config['sources']:
|
||||
slug = '{0}.{1}'.format(self.slug, source['slug'])
|
||||
result = source.get('default', {})
|
||||
result['data'] = Data(slug, self.config, source, context)
|
||||
yield source['slug'], result
|
||||
|
||||
|
||||
class Data(object):
|
||||
'''Encapsulate data from a source'''
|
||||
|
||||
|
|
Reference in New Issue