I am trying to send a HTML newsletter with the simplenews plugin using views. The mailing of HTML via the plugin works flawlessly (after tinkering). I included a View via the Twig Tweak plugin inside the corresponding twig template. My main problem is very similar to this but for Drupal 8. HTML mails require (as far as I know) inline CSS to be displayed correctly in the majority of mail clients. As I use a View, inline CSS get stripped away ("sanititzed" for security I guess).

Is there any possibility for me to use Views with inline CSS as in Drupal 8 I couldn't find the correct line of code to disable this "sanitisation"?


I've been looking into this problem myself for several days, and my conclusion after going through the views code is that views is absolutely dead-set on sanitizing certain data (specifically twig template fields for custom field rewriting) not even writing your own templates can fix that.

Ultimately, my work around for this was to use Display Suite to build a custom display for my node type (which lets me use tokens in custom display suite fields) and then telling views setting up views to output Display Suite content instead of Fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.