From e1b47e5b62ea49af0af3e358d99987d0c09484bb Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 27 Feb 2026 10:13:38 +0000 Subject: [PATCH] Refactor nav_entries_oob into composable shared macro with caller block Replace the shared fallback template with a Jinja macro that each domain (blog, events, market) can call with its own domain-specific nav items. Co-Authored-By: Claude Opus 4.6 --- .../_types/post/admin/_nav_entries_oob.html | 34 ++++++++ .../_types/post/admin/_nav_entries_oob.html | 34 ++++++++ .../_types/post/admin/_nav_entries_oob.html | 80 ------------------- .../browser/templates/macros/nav_entries.html | 58 ++++++++++++++ 4 files changed, 126 insertions(+), 80 deletions(-) create mode 100644 blog/templates/_types/post/admin/_nav_entries_oob.html create mode 100644 events/templates/_types/post/admin/_nav_entries_oob.html delete mode 100644 shared/browser/templates/_types/post/admin/_nav_entries_oob.html create mode 100644 shared/browser/templates/macros/nav_entries.html diff --git a/blog/templates/_types/post/admin/_nav_entries_oob.html b/blog/templates/_types/post/admin/_nav_entries_oob.html new file mode 100644 index 0000000..7a8b8d1 --- /dev/null +++ b/blog/templates/_types/post/admin/_nav_entries_oob.html @@ -0,0 +1,34 @@ +{# OOB swap for nav entries and calendars — blog's version using shared macro #} +{% from 'macros/nav_entries.html' import nav_entries_oob %} + +{% set has_items = (associated_entries and associated_entries.entries) or calendars %} +{% call nav_entries_oob(has_items) %} + {% if associated_entries and associated_entries.entries %} + {% for entry in associated_entries.entries %} + {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar_slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} + +
+
+
{{ entry.name }}
+
+ {{ entry.start_at.strftime('%b %d, %Y at %H:%M') }} + {% if entry.end_at %} – {{ entry.end_at.strftime('%H:%M') }}{% endif %} +
+
+
+ {% endfor %} + {% endif %} + {% if calendars %} + {% for calendar in calendars %} + {% set local_href=events_url('/' + post.slug + '/calendars/' + calendar.slug + '/') %} + + +
{{calendar.name}}
+
+ {% endfor %} + {% endif %} +{% endcall %} diff --git a/events/templates/_types/post/admin/_nav_entries_oob.html b/events/templates/_types/post/admin/_nav_entries_oob.html new file mode 100644 index 0000000..2523112 --- /dev/null +++ b/events/templates/_types/post/admin/_nav_entries_oob.html @@ -0,0 +1,34 @@ +{# OOB swap for nav entries and calendars when toggling associations or editing calendars #} +{% from 'macros/nav_entries.html' import nav_entries_oob %} + +{% set has_items = (associated_entries and associated_entries.entries) or calendars %} +{% call nav_entries_oob(has_items) %} + {% if associated_entries and associated_entries.entries %} + {% for entry in associated_entries.entries %} + {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar_slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} + +
+
+
{{ entry.name }}
+
+ {{ entry.start_at.strftime('%b %d, %Y at %H:%M') }} + {% if entry.end_at %} – {{ entry.end_at.strftime('%H:%M') }}{% endif %} +
+
+
+ {% endfor %} + {% endif %} + {% if calendars %} + {% for calendar in calendars %} + {% set local_href=events_url('/' + post.slug + '/calendars/' + calendar.slug + '/') %} + + +
{{calendar.name}}
+
+ {% endfor %} + {% endif %} +{% endcall %} diff --git a/shared/browser/templates/_types/post/admin/_nav_entries_oob.html b/shared/browser/templates/_types/post/admin/_nav_entries_oob.html deleted file mode 100644 index eecc3d5..0000000 --- a/shared/browser/templates/_types/post/admin/_nav_entries_oob.html +++ /dev/null @@ -1,80 +0,0 @@ -{# OOB swap for nav entries and calendars when toggling associations or editing calendars #} -{% import 'macros/links.html' as links %} - -{# Associated Entries and Calendars - vertical on mobile, horizontal with arrows on desktop #} -{% if (associated_entries and associated_entries.entries) or calendars %} -
- {# Left scroll arrow - desktop only #} - - -
-
- {# Calendar entries #} - {% if associated_entries and associated_entries.entries %} - {% for entry in associated_entries.entries %} - {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar_slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} - -
-
-
{{ entry.name }}
-
- {{ entry.start_at.strftime('%b %d, %Y at %H:%M') }} - {% if entry.end_at %} – {{ entry.end_at.strftime('%H:%M') }}{% endif %} -
-
-
- {% endfor %} - {% endif %} - {# Calendar links #} - {% if calendars %} - {% for calendar in calendars %} - {% set local_href=events_url('/' + post.slug + '/calendars/' + calendar.slug + '/') %} - - -
{{calendar.name}}
-
- {% endfor %} - {% endif %} -
-
- - - - {# Right scroll arrow - desktop only #} - -
-{% else %} - {# Empty placeholder to remove nav items when all are disassociated/deleted #} -
-{% endif %} diff --git a/shared/browser/templates/macros/nav_entries.html b/shared/browser/templates/macros/nav_entries.html new file mode 100644 index 0000000..147d038 --- /dev/null +++ b/shared/browser/templates/macros/nav_entries.html @@ -0,0 +1,58 @@ +{# + Composable scrollable nav entries container. + + Usage: + {% call nav_entries_oob(has_items=True) %} + ... + ... + {% endcall %} + + Each domain (events, blog, market) provides its own items via the caller block. +#} + +{% macro nav_entries_oob(has_items) %} +{% if has_items %} +
+ + +
+
+ {{ caller() }} +
+
+ + + + +
+{% else %} +
+{% endif %} +{% endmacro %}