-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
html_attr docs are misleading / unclear #2817
Copy link
Copy link
Closed
Description
i had a discussion with some of my co workers about escaping strategies and when to use 'html_attr'.
from my point of view, we should add an example when to use html_attr instead of html.
The docs are saying that:
html: escapes a string for the HTML body context.
html_attr: escapes a string for the HTML attribute context.
example 1
following the docs, this wouldn't be best practice, but it seems to be "fine".
#2615 (comment)
{% set untrusted = 'untrusted' %}
<div class="{{ untrusted }}">{{ untrusted }}</a>example 2
if you stick to the docs this should be best practice?
{% set untrusted = 'untrusted' %}
<div class="{{ untrusted | e('html_attr') }}">{{ untrusted }}</a>is there any reason why example1 is wrong?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels