eschmar/css-inliner-bundle
A Symfony Twig extension that inlines CSS into HTML emails using CssToInlineStyles. Wrap content in the cssinline tag and it converts style blocks into inline styles, then strips the originals—ideal for email templates.
Simple twig css inliner for Symfony using CssToInlineStyles.
Composer (Packagist):
composer require eschmar/css-inliner-bundle ^2.0.0 # Symfony ^5.0
# or
composer require eschmar/css-inliner-bundle ^1.0.0 # Symfony ^4.1
# or
composer require eschmar/css-inliner-bundle ^0.2.0 # Symfony ^3.4
app/Appkernel.php (Symfony <4):
new Eschmar\CssInlinerBundle\EschmarCssInlinerBundle(),
This bundle introduces a new tag to twig:
{% cssinline %}
<style>
p {
padding: 8px 15px;
color: #8E2800;
background-color: #FFB03B;
}
</style>
<p>Bananaaa!</p>
{% endcssinline %}
Which inlines all <style> tags and strips them out afterwards. The result:
<p style="background-color: #FFB03B; color: #8E2800; padding: 8px 15px;">Bananaaa!</p>
Nothing more, nothing less. Uses the amazing CssToInlineStyles.
MIT License. Please check CssToInlineStyles for its licensing.
How can I help you explore Laravel packages today?