Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subrenderer = ""
class File(SimpleNamespace):
pass
class TeaserRenderer(Subrenderer):
def enter(self, **kwargs):
yield '<div class="teasers">'
def exit(self, **kwargs):
yield "</div>"
class FAQRenderer(Subrenderer):
def enter(self, **kwargs):
yield '<div class="faq">'
def exit(self, **kwargs):
yield "</div>"
teaser_renderer = TeaserRenderer()
teaser_renderer.register_string_renderer(Teaser, lambda plugin: plugin.text)
teaser_renderer.register_string_renderer(Command, "")
faq_renderer = FAQRenderer()
faq_renderer.register_string_renderer(FAQ, lambda plugin: plugin.text)
faq_renderer.register_string_renderer(Command, "")
faq_renderer.register_string_renderer(File, lambda plugin: plugin.text)
def test_continue_subrenderer(self):
class ContinueSubrenderer(Subrenderer):
def enter(self, **kwargs):
yield '<div class="stuff">'
def exit(self, **kwargs):
yield "</div>"
def reenter(self, **kwargs):
yield from self.exit(**kwargs)
yield from self.enter(**kwargs)
continue_subrenderer = ContinueSubrenderer()
continue_subrenderer.register_string_renderer(Text, lambda plugin: plugin.text)
continue_subrenderer.register_string_renderer(Command, "")
class RegionsWithContinue(SubrendererRegions):
subrenderers = {"continue": continue_subrenderer}
subrenderer = "teasers"
class FAQ(SimpleNamespace):
subrenderer = "faq"
class Command(SimpleNamespace):
subrenderer = ""
class File(SimpleNamespace):
pass
class TeaserRenderer(Subrenderer):
def enter(self, **kwargs):
yield '<div class="teasers">'
def exit(self, **kwargs):
yield "</div>"
class FAQRenderer(Subrenderer):
def enter(self, **kwargs):
yield '<div class="faq">'
def exit(self, **kwargs):
yield "</div>"
teaser_renderer = TeaserRenderer()