CssInlinerBundle
Simple twig css inliner for Symfony using CssToInlineStyles., (*1)
Installation
Composer (Packagist):, (*2)
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):, (*3)
new Eschmar\CssInlinerBundle\EschmarCssInlinerBundle(),
Usage
This bundle introduces a new tag to twig:, (*4)
{% 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:, (*5)
<p style="background-color: #FFB03B; color: #8E2800; padding: 8px 15px;">Bananaaa!</p>
Nothing more, nothing less. Uses the amazing CssToInlineStyles., (*6)
License
MIT License. Please check CssToInlineStyles for its licensing., (*7)