-{% for tag in tab.tags %}
-{%- if not tag.options.private or edit -%}
-{% set classes = [] %}
-{% if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif %}
-{% if tag.options.private and edit %}{% set classes = classes + ['private-tag'] %}{% endif %}
+{% for tag in tags -%}
+
+{%- set classes = [] -%}
+{%- if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif -%}
+{%- if tag.options.private %}{% set classes = classes + ['private-tag'] %}{% endif -%}
{{ tag.name }} |
{{ make_tag_value(tag) }} |
-{%- endif -%}
-{% for subtag in tag.subtags %}
-{%- if (not tag.options.private and not subtag.options.private) or edit -%}
-{% set classes = [] %}
-{% if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif %}
-{% if (tag.options.private or subtag.options.private) and edit %}{% set classes = classes + ['private-tag'] %}{% endif %}
+
+{%- set subtags = [] -%}
+{%- for subtag in tag.subtags %}{% if edit or not subtag.options.private -%}
+{% set _ = subtags.append(subtag) %}
+{%- endif -%}{%- endfor -%}
+
+{%- for subtag in subtags -%}
+{%- set classes = [] -%}
+{%- if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif -%}
+{%- if tag.options.private or subtag.options.private %}{% set classes = classes + ['private-tag'] %}{% endif -%}
{% if loop.last %}└{% else %}├{% endif %} {{ subtag.name }} |
{{ make_tag_value(subtag) }} |
-{%- endif -%}
-{% endfor %}
-{% endfor %}
+{%- endfor -%}
+
+{%- endfor -%}