Filters
raw
Introduction
The raw
filter allows you to display content without escaping variables. It is useful when you need to render content that should not be automatically converted into safe text, such as when you want to display HTML tags or scripts in the final output.
Example of use
Example of how to use the raw
filter to render a script directly in a template:
In this case, the output will be the JavaScript code that triggers the alert:
In this example, the raw
filter is applied to the content
variable to ensure that the tags are rendered correctly in the final output instead of being escaped. When rendered in a web page, for instance, the JavaScript alert will be displayed.