Overview
The |safe
filter allows HTML stored in variables to be rendered directly in your templates. Use it when you trust the HTML content to be safe from XSS vulnerabilities.
Example
If you have HTML content stored in a variable, you can mark it as safe for rendering using the |safe
filter. For instance:
{{ customer.extra_data.my_smart_field|safe }}
This code snippet tells the template engine to render the HTML content of customer.extra_data.my_smart_field
directly onto the web page without escaping it.
Use this approach cautiously and ensure the content does not contain any user-inputted data to mitigate security risks.