Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only add <hr> to options when they are any #79

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/static/styles.sass
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,7 @@ p
background-color: #f5f5f5

.custom-link
color: $colDefault
color: $colDefault

.small-hr
height: 1px
5 changes: 2 additions & 3 deletions frontend/templates/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load sass_tags %}
{% load i18n %}
{% load menu %}
{% load menu_utils %}
{% load utils %}

{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
Expand Down Expand Up @@ -84,9 +84,8 @@
<input name="language" type=hidden value={{ locale.code }}>
</form>
{% endfor %}
<hr class="mt-2 mb-1">
<div class="d-flex flex-column">
{% block extra_options %}{% endblock %}
{% filter prefix:"<div><hr class='mt-2 mb-1 small-hr'></div>" %}{% block extra_options %}{% endblock %}{% endfilter %}
</div>
</div>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tags for drawing the menu"""
from django import template
from django.template.defaultfilters import stringfilter

from tenants.utils import create_tenant_string

Expand All @@ -12,3 +13,10 @@ def draw_menu(context, key, use_tenant=False):
if use_tenant:
key = create_tenant_string(context.request.tenant, key)
return {"menu": context["menus"][key]}


@register.filter
@stringfilter
def prefix(value, args):
"""Adds prefix if value is not empty"""
return str(args) + value if value else value