Jinja2 unescaping the sequence

69 Views Asked by At

I am working on a jinja2 template in python where autoescape=true flag is required due to privacy constraint. Since the autoescaping is enabled, jinja template ouputs the ascii value i.e >> instead of >> symbols.

Is their a way where I can still output the > sign while still enabling the autoescape flag?

item: abcd >> efgh

Sample Jinja2 template:

{{ item }} 

Current output: abcd >> efgh

Expected output: abcd >> efgh

Expected output: abcd >> efgh

1

There are 1 best solutions below

0
On

You can manually mark a specific variable as safe with the safe filter:

{{ item|safe }} 

But then you need to make sure that item does not contain any harmful content (replace them manually).