def render(self, ctx=None):
'''
Only render if condition applies
:param ctx: rendering context in which the method was called
:rtype: `Bits`
:return: rendered value of the container
'''
if ctx is None:
ctx = RenderContext()
self._initialize()
if self in ctx:
self._current_rendered = self._in_render_value()
else:
ctx.push(self)
if self._evaluate_condition(ctx):
super(Conditional, self).render(ctx)
else:
self.set_current_value(empty_bits)
ctx.pop()
return self._current_rendered
评论列表
文章目录