eschmar/css-inliner-bundle

Simple twig css inliner for Symfony 4.

Installs: 85 160

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 1

Open Issues: 1

Type:symfony-bundle

v2.0.0 2020-03-20 14:32 UTC

This package is auto-updated.

Last update: 2024-10-21 00:07:40 UTC


README

Simple twig css inliner for Symfony using CssToInlineStyles.

Installation

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(),

Usage

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.

License

MIT License. Please check CssToInlineStyles for its licensing.