Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cssinliner Extra

Cssinliner Extra Laravel Package

twig/cssinliner-extra

Twig CssInliner Extension adds the inline_css filter to Twig templates, letting you inline CSS into HTML output. Useful for building email-friendly HTML with styles converted to inline attributes during rendering.

View on GitHub
Deep Wiki
Context7

twig/cssinliner-extra is a Twig extension that adds the inline_css filter for turning CSS rules into inline style attributes in HTML—ideal for email templates and environments with limited CSS support. It integrates cleanly with Twig and follows the official filter behavior.

Features:

  • inline_css filter to inline CSS into rendered HTML
  • Improves compatibility for HTML emails and constrained clients
  • Simple Twig usage with minimal setup
  • Works with existing HTML/CSS without changing template structure
Frequently asked questions about Cssinliner Extra
How do I install twig/cssinliner-extra in a Laravel project using Twig?
Run `composer require twig/cssinliner-extra` in your project directory. Then register the extension in your Twig configuration (e.g., `config/twig.php`) by adding it to the `extensions` array. No additional Laravel-specific setup is required beyond Twig’s standard extension registration.
Can I use this package with Laravel Blade templates?
No, this package only works with Twig templates. Laravel Blade uses a different syntax and templating engine, so you’ll need alternatives like Premailer or MJML for Blade-based email projects. Workarounds (e.g., pre-processing Blade to Twig) are unsupported and not recommended.
What Laravel versions does twig/cssinliner-extra support?
The package itself doesn’t enforce Laravel version constraints, but it requires Twig 1.x or 2.x. Ensure your Laravel project’s Twig version is compatible (e.g., Laravel 8+ uses Twig 2.x). Check the package’s `composer.json` for Twig version requirements and align your Laravel setup accordingly.
Does this package support complex CSS selectors like @media queries or :hover?
No, the package silently drops unsupported CSS features like `@media`, `:hover`, and complex selectors. For advanced email designs, you’ll need to manually inline these styles or redesign templates to avoid them. Test thoroughly in email clients like Outlook or Gmail to catch missing styles.
How do I apply the inline_css filter in a Twig email template?
Use the filter directly in your Twig template like this: `{{ content|inline_css }}`. This processes the HTML and converts embedded or external CSS into inline `style` attributes. For example, include a Twig partial with CSS and apply the filter to the rendered output before sending the email.
Is this package safe for production use? Are there security risks?
The package is generally safe if configured correctly, but fetching external CSS (`remote: true`) introduces XSS risks. Always sanitize inputs and disable `remote` unless absolutely necessary. For production, pre-process emails during build time (e.g., via Artisan commands) to avoid runtime vulnerabilities.
Will this package break if I update Laravel or Twig?
The package’s maintenance status is unclear due to lack of recent updates, so breaking changes are a risk. Monitor the GitHub repository for updates and consider forking or replacing it if Laravel/Twig updates introduce incompatibilities. Test thoroughly after major version upgrades.
How can I optimize performance for high-volume email campaigns?
Avoid runtime inlining for large campaigns—use Laravel’s task scheduling or CI/CD pipelines to pre-process emails during build time. Cache inlined HTML in Redis or Memcached, or queue email processing with Laravel Queues to distribute the load. For critical paths, pre-generate inlined templates.
Are there alternatives to twig/cssinliner-extra for Laravel Blade?
Yes, for Blade templates, consider Premailer (PHP-based) or MJML (markup language for responsive emails). Both support CSS inlining and are more aligned with Laravel’s ecosystem. If you’re using Twig, this package is a lightweight option, but evaluate its maintenance risks before committing.
Can I use this package with Laravel’s email system (e.g., Mailable classes)?
Yes, integrate the package by applying the `inline_css` filter in your Twig email templates or within the `build()` method of a Mailable class. For example, render the Twig template first, then pass the output through the filter before sending. Combine with Laravel’s email queueing for scalability.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport