{% macro card_title(pac_info) %} {% if pac_info.display_name %} {{ pac_info.display_name }} {% endif %} {% endmacro %} {% macro card_image(pac_info) %} {% if pac_info.image_url %}
{% elif pac_info.main_category %}
{{ pac_info.main_category.key }}
{% endif %} {% endmacro %} {% macro card_main(pac_info) %}
{{ card_image(pac_info) }} {{ card_category_info(pac_info) }}
{% endmacro%} {% macro card_category_info(pac_info) %} {% if pac_info.main_category %} {% set c = pac_info.main_category %} {{ card_info_block(c.segments_as_dict().items()) }} {% endif %} {% endmacro %} {% macro card_info_block(segments, format_keys=True) %} {# segments: iterable of (key, value) 2-tuples - NOT a dict.items()-only call, so non-unique/empty labels don't silently lose rows by first collapsing into a dict (see key_value_table in base-components.jinja.html for the same fix). format_keys runs raw snake_case keys (PAC-CAT segment names) through title_format - set it False for keys that are already a human-formatted label (e.g. an attribute's own .label, like "CAS No." or "EG-Nr."), which title_format would otherwise mangle (title-cases "CAS" down to "Cas"). #}
{% for k, v in segments %} {% if k != "key" %}
{% if k %}{{ title_format(k) if format_keys else k }}{% else %}No Key{% endif %}
{{ render_text(v) }}
{% endif %} {% endfor %}
{% endmacro%} {% macro qualification_state(pac_info) %} {% if pac_info.qualification_state %} {{pac_info.qualification_state.label }}: {{pac_info.qualification_state.value }} {% endif %} {% endmacro %}