Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I want to send an HMTL email that contains an HTML token.
Token HTML contains style attributes which are removed by Drupal core. \Drupal\Core\Render\Markup
How can I return intentional unsafe HTML through tokens?
Steps to reproduce
1. Create a custom token
2. return HTML with style attributes like
<div align="left" class="custom-class" style="font-size: 14px; vertical-align: top; padding-bottom: 15px; color: red;">Hello World</div>
3. Notice that token output will only contain
<div align="left" class="custom-class">Hello World</div>
Proposed resolution
How can I return unsafe/unfiltered HTML through tokens?
Comments
Comment #2
andregp CreditAttribution: andregp at CI&T commented@khaldoon_masud the maintainers may have a good reason for making the tokens tokens be returned filtered.
Have you tried talking with them about this feature request?
It's easier to reach maintainers through the Drupal slack. I believe you could try there (if you haven't already) to discuss about this feature and see their opinion.