misc: fix split template tag (#48507)
This commit is contained in:
parent
e460043cfb
commit
fd03e88b0b
|
@ -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
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue