nerds-and-company / css-to-inline-styles-twig-extension
A Twig extension to insert css as inline styles with a tag
Installs: 25 006
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 6
Forks: 2
Open Issues: 0
Requires
- php: >=7.2.5
- tijsverkoyen/css-to-inline-styles: ^2.0
- twig/twig: >=3.0
Requires (Dev)
- phpunit/phpunit: ~4.8|~5.4
README
Based on work by Roberto Trunfio on https://github.com/robertotru/ToInlineStyleEmailBundle
Makes use of https://github.com/tijsverkoyen/CssToInlineStyles by Tijs Verkoyen
Installation
This twig extension is installed through Composer. Run the following command from the root of your project:
composer require nerds-and-company/css-to-inline-styles-twig-extension
This will add nerds-and-company/css-to-inline-styles-twig-extension as a requirement to your project's composer.json file and install the source-code into the vendor/nerds-and-company/css-to-inline-styles-twig-extension directory
Add the extension to the Twig_Environment
:
use NerdsAndCompany\CssToInlineStyles\Twig\InlineCssExtension; use Twig\Environment; $twig = new Environment(...); $twig->addExtension(new InlineCssExtension());
Usage
{% inlinecss '/absolute/path/file.css' %}
<tag>Html to be converted</tag>
{% endinlinecss %}