Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eschmar/css-inliner-bundle

Simple twig css inliner for PHP Symfony
https://github.com/eschmar/css-inliner-bundle

csstoinlinestyles inline-css php symfony symfony-bundle twig

Last synced: 7 days ago
JSON representation

Simple twig css inliner for PHP Symfony

Awesome Lists containing this project

README

        

# CssInlinerBundle
Simple twig css inliner for Symfony using [CssToInlineStyles](https://github.com/tijsverkoyen/CssToInlineStyles).

# Installation
Composer (Packagist):
```sh
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):
```php
new Eschmar\CssInlinerBundle\EschmarCssInlinerBundle(),
```

# Usage
This bundle introduces a new tag to twig:

```html
{% cssinline %}

p {
padding: 8px 15px;
color: #8E2800;
background-color: #FFB03B;
}

Bananaaa!


{% endcssinline %}
```

Which inlines all ```` tags and strips them out afterwards. The result:

```html
<p style="background-color: #FFB03B; color: #8E2800; padding: 8px 15px;">Bananaaa!</p>
```

Nothing more, nothing less. Uses the amazing [CssToInlineStyles](https://github.com/tijsverkoyen/CssToInlineStyles).

# License
MIT License. Please check [CssToInlineStyles](https://github.com/tijsverkoyen/CssToInlineStyles) for its licensing.