misc: fix split template tag (#48507)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2020-11-16 16:31:02 +01:00
parent e460043cfb
commit fd03e88b0b
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 3 additions and 1 deletions

View File

@ -304,7 +304,7 @@ def get(obj, key):
@register.filter
def split(string, separator=' '):
return (string or '').split(separator)
return (force_text(string) or '').split(separator)
@register.filter

View File

@ -134,6 +134,8 @@ def test_split():
assert t.render(Context({'plop': 'ab cd ef'})) == 'ab<br>cd<br>ef<br>'
t = Template('{% for x in plop|split:"|" %}{{x}} {% endfor %}')
assert t.render(Context({'plop': 'ab|cd|ef'})) == 'ab cd ef '
t = Template('{% for x in plop|split:"|" %}{{x}} {% endfor %}')
assert t.render(Context({'plop': 42})) == '42 '
def test_strip_templatetag():