From acad4bf227de4679bebef27aef48f666e0b2514d Mon Sep 17 00:00:00 2001 From: Talmiz Ahmed <55018280+HashTalmiz@users.noreply.github.com> Date: Thu, 8 Oct 2020 18:38:53 +0530 Subject: [PATCH] fix: Introduce new macros to keep reusable tag navigation items (#81) --- partials/operations/by_tags.html | 68 +++-------------------- partials/operations/by_tags_no_root.html | 66 +++------------------- partials/operations/tag_nav_item_pub.html | 23 ++++++++ partials/operations/tag_nav_item_sub.html | 23 ++++++++ 4 files changed, 61 insertions(+), 119 deletions(-) create mode 100644 partials/operations/tag_nav_item_pub.html create mode 100644 partials/operations/tag_nav_item_sub.html diff --git a/partials/operations/by_tags.html b/partials/operations/by_tags.html index 65e9392f9..c782a1ce3 100644 --- a/partials/operations/by_tags.html +++ b/partials/operations/by_tags.html @@ -1,3 +1,6 @@ +{% from "./tag_nav_item_sub.html" import tagNavItemSub %} +{% from "./tag_nav_item_pub.html" import tagNavItemPub %} + {% if asyncapi.hasTags() %} {% for categorytags in asyncapi.tags() %}
@@ -13,41 +16,12 @@
{% for channelName, channel in asyncapi.channels() %} - {% if channel.publish() and channel.publish().hasTags() and channel.publish() | containTags(categorytags) %} - - - Pub - - {% if channel.publish().summary() %} - - {{ channel.publish().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {% if channel.publish() and channel.publish().hasTags() and channel.publish() | containTags(categorytags) %} + {{ tagNavItemPub(channel, channelName) }} {% endif %} {% if channel.subscribe() and channel.subscribe().hasTags() and channel.subscribe() | containTags(categorytags) %} - - {% if channel.deprecated %} - - {% endif %} - - Sub - - {% if channel.subscribe().summary() %} - - {{ channel.subscribe().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemSub(channel, channelName) }} {% endif %} {% endfor %}
@@ -72,37 +46,11 @@
{% for channelName, channel in asyncapi.channels() %} {% if channel.hasPublish() and (not channel.publish().hasTags() or not channel.publish() | containTags(asyncapi.tags())) %} - - - Pub - - {% if channel.publish().summary() %} - - {{ channel.publish().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemPub(channel, channelName) }} {% endif %} {% if channel.hasSubscribe() and (not channel.subscribe().hasTags() or not channel.subscribe() | containTags(asyncapi.tags())) %} - - - Sub - - {% if channel.subscribe().summary() %} - - {{ channel.subscribe().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemSub(channel, channelName) }} {% endif %} {% endfor %}
diff --git a/partials/operations/by_tags_no_root.html b/partials/operations/by_tags_no_root.html index 8fc48a351..e59b3caa0 100644 --- a/partials/operations/by_tags_no_root.html +++ b/partials/operations/by_tags_no_root.html @@ -1,3 +1,6 @@ +{% from "./tag_nav_item_sub.html" import tagNavItemSub %} +{% from "./tag_nav_item_pub.html" import tagNavItemPub %} + {% for tag in asyncapi | operationsTags %}
@@ -14,40 +17,11 @@
{% for channelName, channel in asyncapi.channels() %} {% if channel.publish() and channel.publish().hasTags() and channel.publish() | containTags(tag) %} - - - Pub - - {% if channel.publish().summary() %} - - {{ channel.publish().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemPub(channel, channelName) }} {% endif %} {% if channel.subscribe() and channel.subscribe().hasTags() and channel.subscribe() | containTags(tag) %} - - {% if channel.deprecated %} - - {% endif %} - - Sub - - {% if channel.subscribe().summary() %} - - {{ channel.subscribe().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemSub(channel, channelName) }} {% endif %} {% endfor %}
@@ -70,37 +44,11 @@
{% for channelName, channel in asyncapi.channels() %} {% if channel.hasPublish() and (not channel.publish().hasTags() or not channel.publish() | containTags(asyncapi | operationsTags())) %} - - - Pub - - {% if channel.publish().summary() %} - - {{ channel.publish().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemPub(channel, channelName) }} {% endif %} {% if channel.hasSubscribe() and (not channel.subscribe().hasTags() or not channel.subscribe() | containTags(asyncapi | operationsTags())) %} - - - Sub - - {% if channel.subscribe().summary() %} - - {{ channel.subscribe().summary() }} - - {% else %} -
- {{ slicedString(channelName, 'padding-top: 2px;') }} -
- {% endif %} -
+ {{ tagNavItemSub(channel, channelName) }} {% endif %} {% endfor %}
diff --git a/partials/operations/tag_nav_item_pub.html b/partials/operations/tag_nav_item_pub.html new file mode 100644 index 000000000..9ac707e5c --- /dev/null +++ b/partials/operations/tag_nav_item_pub.html @@ -0,0 +1,23 @@ +{% from "../sliced-string.html" import slicedString %} + + +{% macro tagNavItemPub(channel, channelName) %} + + + + Pub + + {% if channel.publish().summary() %} + + {{ channel.publish().summary() }} + + {% else %} +
+ {{ slicedString(channelName, 'padding-top: 2px;') }} +
+ {% endif %} +
+ +{% endmacro %} \ No newline at end of file diff --git a/partials/operations/tag_nav_item_sub.html b/partials/operations/tag_nav_item_sub.html new file mode 100644 index 000000000..7d797e510 --- /dev/null +++ b/partials/operations/tag_nav_item_sub.html @@ -0,0 +1,23 @@ +{% from "../sliced-string.html" import slicedString %} + + +{% macro tagNavItemSub(channel, channelName) %} + + + + Sub + + {% if channel.subscribe().summary() %} + + {{ channel.subscribe().summary() }} + + {% else %} +
+ {{ slicedString(channelName, 'padding-top: 2px;') }} +
+ {% endif %} +
+ +{% endmacro %} \ No newline at end of file