betty.jinja2 package¶
Submodules¶
- betty.jinja2.filter module
- betty.jinja2.filter.filter_base64
- betty.jinja2.filter.filter_file
- betty.jinja2.filter.filter_flatten
- betty.jinja2.filter.filter_format_datey
- betty.jinja2.filter.filter_format_degrees
- betty.jinja2.filter.filter_hashid
- betty.jinja2.filter.filter_image
- betty.jinja2.filter.filter_json
- betty.jinja2.filter.filter_localize
- betty.jinja2.filter.filter_map
- betty.jinja2.filter.filter_negotiate_dateds
- betty.jinja2.filter.filter_negotiate_localizeds
- betty.jinja2.filter.filter_paragraphs
- betty.jinja2.filter.filter_public_css
- betty.jinja2.filter.filter_public_js
- betty.jinja2.filter.filter_select_dateds
- betty.jinja2.filter.filter_select_localizeds
- betty.jinja2.filter.filter_sort_localizeds
- betty.jinja2.filter.filter_static_url
- betty.jinja2.filter.filter_unique
- betty.jinja2.filter.filter_url
- betty.jinja2.filter.filter_walk
- betty.jinja2.test module
- betty.jinja2.test.test_date_range
- betty.jinja2.test.test_end_of_life_event
- betty.jinja2.test.test_entity
- betty.jinja2.test.test_has_files
- betty.jinja2.test.test_has_generated_entity_id
- betty.jinja2.test.test_has_links
- betty.jinja2.test.test_linked_data_dumpable
- betty.jinja2.test.test_start_of_life_event
- betty.jinja2.test.test_subject_role
- betty.jinja2.test.test_user_facing_entity
- betty.jinja2.test.test_witness_role
Module contents¶
Provide rendering utilities using Jinja2.
- class betty.jinja2.Environment(app)[source]¶
Bases:
Environment- property context_class : type[Context]¶
The template context holds the variables of a template. It stores the values passed to the template and also the names the template exports. Creating instances is neither supported nor useful as it’s created automatically at various stages of the template evaluation and should not be created by hand.
The context is immutable. Modifications on
parentmust not happen and modifications onvarsare allowed from generated template code only. Template filters and global functions marked aspass_context()get the active context passed as first argument and are allowed to access the context read-only.The template context supports read only dict operations (get, keys, values, items, iterkeys, itervalues, iteritems, __getitem__, __contains__). Additionally there is a
resolve()method that doesn’t fail with a KeyError but returns anUndefinedobject for missing variables.
- filters : --is-rst--dict[str, Callable[..., Any]]¶
- globals : --is-rst--dict[str, Any]¶
- tests : --is-rst--dict[str, Callable[..., bool]]¶
- class betty.jinja2.Jinja2Provider[source]¶
Bases:
object- property filters : dict[str, Callable[[...], Any]]¶
- property globals : dict[str, Any]¶
- property tests : dict[str, Callable[[...], bool]]¶
- class betty.jinja2.Jinja2Renderer(environment, configuration)[source]¶
Bases:
Renderer- property file_extensions : set[str]¶
- betty.jinja2.context_app(context)[source]¶
Get the current app from the Jinja2 context.