misc: introduce a {% newline %} tag (#57622)
This commit is contained in:
parent
1e7f76648a
commit
71b0291a4a
|
@ -1271,3 +1271,9 @@ def test_site_options_booleans(pub):
|
|||
assert Template('{% if something_false == "false" %}hello{% endif %}').render(context) == 'hello'
|
||||
assert Template('{% if something_false == True %}hello{% endif %}').render(context) == ''
|
||||
assert Template('{% if something_false == "true" %}hello{% endif %}').render(context) == ''
|
||||
|
||||
|
||||
def test_newline(pub):
|
||||
context = pub.substitutions.get_context_variables()
|
||||
assert Template('a{% newline %}b').render(context) == 'a\nb'
|
||||
assert Template('a{% newline windows=True %}b').render(context) == 'a\r\nb'
|
||||
|
|
|
@ -853,3 +853,8 @@ def qrcode_filter(value, name=None):
|
|||
upload = upload_storage.PicklableUpload(name or 'qrcode.png', 'image/png')
|
||||
upload.receive([buf.getvalue()])
|
||||
return upload
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def newline(windows=False):
|
||||
return '\r\n' if windows else '\n'
|
||||
|
|
Loading…
Reference in New Issue