1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# HTML Filters ## escape_html Escapes HTML special characters. ```html {{ "<script>alert('xss')</script>" | escape_html }} {# Output: <script>alert('xss')</script> #} ``` ## safe Marks content as safe (won't be escaped). ```html {{ "<b>bold</b>" | safe }} {# Output: <b>bold</b> (not escaped) #} ``` ## strip_tags Removes HTML tags. ```html {{ "<p>Hello <b>World</b></p>" | strip_tags }} {# Output: Hello World #} ```