1

I'm trying to create an email newsletter template to make it easier to send out blog newsletters by looping over entries and generating the email straight out of craft. I did this often with Wordpress.

However I'm getting twig syntax errors because of the inline CSS. I know you can do this <style>{{ source('file.css') }}</style> but that's not going to cut it for all the tables I need to add inline CSS to.

Am I missing a Twig filter that I could wrap all my HTML code it?

Just to be clear I am only trying to generate, not send the email newsletter through Craft.

| improve this question | | | | |
1

You can include standard HTML in Twig templates. So something like this would work:

<table style="background-color: gray">

You don't have to use Twig filters to add CSS or CSS files. Although you could create some CSS variables using {% set gray = '#eee' %} or {% set border = 'border: 1px solid black' %} for repeated styles such as colors, borders, etc., and then reference those like this, using the variable name:

<table style="background-color: {{ gray }}; {{ border }}>
| improve this answer | | | | |

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.