Skip to content

Commit b8912a4

Browse files
fix: treat str input as None in the person_link tag (ietf-tools#3832)
1 parent eef29cf commit b8912a4

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

ietf/person/templatetags/person_filters.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,19 @@ def person_by_name(name):
3737

3838
@register.inclusion_tag("person/person_link.html")
3939
def person_link(person, **kwargs):
40+
"""Render a link to a Person
41+
42+
If person is None or a string, renders as a span containing '(None)'.
43+
"""
44+
if isinstance(person, str):
45+
# If person is a string, most likely an invalid template variable was referenced.
46+
# That normally comes in as an empty string, but may be non-empty if string_if_invalid
47+
# is set. Translate strings into None to try to get consistent behavior.
48+
person = None
4049
title = kwargs.get("title", "")
4150
cls = kwargs.get("class", "")
4251
with_email = kwargs.get("with_email", True)
43-
if person:
52+
if person is not None:
4453
plain_name = person.plain_name()
4554
name = (
4655
person.name

0 commit comments

Comments
 (0)