def render(self, region, context, timeout=None):
"""render(self, region, context, *, timeout=None)
Render a single region using the context passed
If ``timeout`` is ``None`` caching is disabled.
.. note::
You should treat anything except for the ``region`` and ``context``
argument as keyword-only.
"""
if timeout is not None:
key = self.cache_key(region)
html = cache.get(key)
if html is not None:
return html
html = mark_safe(''.join(
self._renderer.render_plugin_in_context(plugin, context)
for plugin in self._contents[region]
))
if timeout is not None:
cache.set(key, html, timeout=timeout)
return html
评论列表
文章目录