Skip to content

Commit

Permalink
Add a translations_from template tag
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Feb 12, 2024
1 parent a98f849 commit c8cac61
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions feincms3/templatetags/feincms3.py
Expand Up @@ -158,6 +158,19 @@ def translations(iterable, languages=None):
]


@register.simple_tag
def translations_from(*iterables, languages=None):
t = {
code: {"code": code, "name": name, "object": None}
for code, name in (languages or settings.LANGUAGES)
}
for iterable in iterables:
if iterable and not isinstance(iterable, str):
for obj in iterable:
t[obj.language_code]["object"] = obj
return t.values()


@register.simple_tag
def maybe_target_blank(href, *, attributes='target="_blank" rel="noopener"'):
"""
Expand Down

0 comments on commit c8cac61

Please sign in to comment.