twig/html-extra
Twig HTML Extension adds handy helpers to Twig: a data_uri filter for RFC 2397 data URLs, an html_classes function to conditionally build CSS class strings, and an html_cva function for managing class variants via a Cva object.
html_cva) for responsive design, dark mode toggles, or A/B testing without hardcoding logic in templates.data_uri).data_uri.Adopt if:
data_uri for embedded assets).Look elsewhere if:
For Executives: "This package lets our frontend team build dynamic, maintainable UI components faster by handling repetitive HTML logic (like class merging or inline assets) in Twig—reducing manual errors and JavaScript overhead. It’s a lightweight, MIT-licensed tool that aligns with our Twig adoption roadmap, cutting dev time for responsive design and theming without sacrificing performance."
For Engineers: *"Twig/html-extra gives us three key Twig functions:
data_uri: Embed assets (e.g., icons) directly in HTML via RFC 2397—no extra HTTP requests.html_classes: Safely merge classes conditionally (e.g., {{ 'btn btn--primary'|html_classes({ 'btn--disabled': isDisabled }) }}).html_cva: Generate class variants programmatically (e.g., for dark mode or A/B tests).
It’s battle-tested, MIT-licensed, and integrates seamlessly with Laravel/Inertia. Let’s prototype it for our [Component X] to see if it cuts template complexity by 20%."*How can I help you explore Laravel packages today?