Skip to main content

assets-push-bundle

Period
2021 – 2024
Kind
Symfony Bundle
Status
archived
License
Open Source
Website
github.com/Braunstetter/assets-push-bundle

assets-push-bundle was one of those projects where I thought: it's obvious that something like this should exist.

From inside a Twig partial, be able to say: this component needs this CSS and this JavaScript. And in the final HTML, the assets show up once, in the right place — not loaded globally for every page, but not manually stitched together either.

The foundation was rybakit/twig-deferred-extension. The extension gave me the deferred rendering I needed to collect the assets at the end of the render pass.

With Twig 4, the API changed. The deferred extension hasn't run cleanly since, several users have reported it (Issue #20, Issue #22). The bug is known, a fix is not in sight.

As long as the extension doesn't work with modern Twig, I can't in good conscience recommend the bundle for new projects. The entry stays here anyway. The bundle worked, it was a clean solution to a real problem — and the standstill is not in my code.

If I were to build this again today, I'd either drop a small Twig extension directly into the project — or solve it declaratively via YAML, the way Sylius does it with its Twig Hooks.