I am currently trying to avoid a variable using django template filters, as shown below. I use the jinja2 template engine instead of the simple django primary template engine.
{{ my_variable|escape|linebreaks }}
the output of a line with newline characters is as follows:
Lorem ipsum <br /> dolor sit amet <br />rg srg gs rgsr rsg serg<br />r srg
Perfectly
<br />
it is not intended to be reset, as it is added by the linebreaks filter. There are no html tags with source string.
I tried:
{{ my_variable|linebreaks|escape }}
But it turns out to be even worse:
<p>Lorem ipsum <br /> dolor sit amet <br />rg srg</p> <p>gs rgsr rsg serg<br />r srg</p>
Does anyone know if I did something wrong using the template filter and / or could point me in the right direction?
Thanks.
source share