Simplify template code

This commit is contained in:
Jeremy Stretch 2023-11-01 15:03:33 -04:00
parent f181b14858
commit bfbcc6bbac

View File

@ -1,11 +1,7 @@
SEARCH_RESULT_ATTRS = """
{% for name, value in record.display_attrs.items %}
{% with url=value.get_absolute_url %}
<span class="badge bg-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{ name|bettertitle }}">
{% if url %}<a href="{{ url }}">{% endif %}
{{ value }}
{% if url %}</a>{% endif %}
</span>
{% endwith %}
<span class="badge bg-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{ name|bettertitle }}">
{{ value|linkify }}
</span>
{% endfor %}
"""