RenderChain

class mnemosyne.libmnemosyne.render_chain.RenderChain(component_manager)

A RenderChain details the operations needed to get from the raw data in a card to a representation of its question and answer, in a form either suitable for displaying in a browser, or exporting to a text file, ... .

First the raw data is sent through Filters, which perform operations which can be useful for many card types, like expanding relative paths.

Then this data is assembled in the right order in a Renderer, which can be card type specific.

‘filters’: list of Filter classes ‘renderers’: list or Renderer classes

Plugins can add Filters or Renderers for a new card type to a chain at run time.

component_type = 'render_chain'
filter(filter_class)
filters = []
id = 'default'
register_filter(filter_class, in_front=False)

‘filter_class’ should be a class, not an instance.

register_filter_at_back(filter_class, before=[])

Register a filter at the back of the render chain, but before a list of other filters already in the chain. The list should contain class names. (Using strings instead of classes means a plugin writer does not need to import the filters he wants to use in this list.)

‘filter_class’ should be a class, not an instance.

register_filter_at_front(filter_class, after=[])

Register a filter at the very front of the render chain, but after a list of other filters already in the chain. The list should contain class names. (Using strings instead of classes means a plugin writer does not need to import the filters he wants to use in this list.)

‘filter_class’ should be a class, not an instance.

register_renderer(renderer_class)

‘renderer_class’ should be a class, not an instance.

render_answer(card, **render_args)
render_question(card, **render_args)
renderer_for_card_type(card_type)
renderers = []
unregister_filter(filter_class)

‘filter_class’ should be a class, not an instance.

unregister_renderer(renderer_class)

‘renderer_class’ should be a class, not an instance.

Previous topic

CardTypeConverter

Next topic

Filter

This Page