## {{ release.version.as_tag() }} ({{ release.tagged_date.strftime('%Y-%m-%d') }})

_This release is published under the MIT License._

{% import ".macros.j2" as macros %}
{#- Capture the output of the macro in compact mode to a variable -#}
{%- set release_body = macros.render_changelog_entry(release.elements, compact=True) %}

{#- Print the captured output, trimming extra whitespace from the whole block -#}
{%- set release_body_trimmed = release_body | trim -%}
{% if release_body_trimmed %}
{{ release_body_trimmed }}
{% else %}
_No user-facing changes._
{% endif %}

{# Get the list of all releases, sorted from newest to oldest #}
{%- set all_releases = context.history.released.values() | list | sort(attribute='version', reverse=true) -%}

{# Check if there is a previous release to compare against (list must have more than one item) #}
{%- if all_releases | length > 1 -%}
{%- set prev_release = all_releases[1] -%}
{%- set prev_version_tag = prev_release.version.as_tag() -%}
{%- set new_version_tag = release.version.as_tag() -%}
{%- set compare_link = prev_version_tag | compare_url(new_version_tag) -%}

---

**Detailed Changes**: [{{ prev_version_tag }}...{{ new_version_tag }}]({{ compare_link }})
{%- else -%}
{#- This is the first release, so there's no previous version to compare to. -#}
{%- endif %}
