Add a macro for generating current service links

This is a convenient way of being able to link into pages of the the app
from guidance. It handles the case where the current service is not
known, either because the user hasn’t chosen one, or because they’re not
signed in.

This commit also cleans up some unused Jinja imports.
This commit is contained in:
Chris Hill-Scott
2020-02-19 08:20:38 +00:00
parent f4e4de0d03
commit 46a4e1c612
6 changed files with 41 additions and 41 deletions

View File

@@ -0,0 +1,7 @@
{% macro current_service_link(endpoint, link_text) %}
{% if current_service %}
<a class="govuk-link" href="{{ url_for(endpoint, service_id=current_service.id) }}">{{ link_text }}</a>
{% else %}
<b class="govuk-!-font-weight-bold">{{ link_text|capitalize }}</b>
{% endif %}
{% endmacro %}