Jinja2 trim CR when rendering

Viewed 35

I was trying to figure out why Jinja2 is triming my \r out of my model. I've got something like this :

Something useful\r\n
And again\r\n

Which then is rendered like this :

Something useful\n
And again\n

And this seems to be known as this link shows : https://github.com/ansible/ansible/issues/22676

As drewdogg is demonstrating here :

>>> t = Template("{{ 'lorem\r\nipsum' }}")
>>> t.render()
u'lorem\nipsum'

Why is this happening? Can I do something to preserve my \r that are necessary for me? The only solutions I came accross was to explicitly write :

{{ '\r\n' }}

Or worse replace, either in Jinja2 or Python3...

Has anybody came over this problem and found a solution?

Thanks a lot :)

0 Answers
Related