csp_unsafe_inline_style - Twig Filter
Info
This feature is available in Contao 5.3.2 and later.
Adds a CSP hash for a given inline style or attributes object and also adds the ‘unsafe-hashes’ source to the directive automatically.
Warning
Only pass trusted styles to this filter!
Usage with a simple inline CSS style string:
<div style="{{ 'color: red'|csp_unsafe_inline_style }}">Usage with an HtmlAttributes object:
<div{{ attrs().addStyle({ color: 'red' })|csp_unsafe_inline_style }}>{% set attributes = attrs()
.addStyle({ color: 'red' })
%}
<div{{ attributes|csp_unsafe_inline_style }}>