dpolac/twig-lambda
Adds lambda and arrow-function syntax to Twig templates, letting you write inline closures like map((x) => x * 2) directly in your templates. A small, focused extension for cleaner data transformations without custom filters or PHP callbacks.
map, filter, reduce, sorting). That directly informs whether a feature like "customizable dashboards," "user-defined report filters," or "conditional content blocks" can be delivered in the templating layer versus requiring new controller endpoints or service classes.Consider it when:
Look elsewhere when:
map/filter/reduce/sort filters largely cover this. Upgrading Twig is a better investment than adding a dependency.Illuminate\Support\Collection already provides map/filter/reduce; pushing lambdas into Blade is a step away from the framework's grain.Gate before adoption: verify the version constraint against your PHP runtime and Twig version, run it under your template linting and sandbox policy, and confirm a rollback path. Absent that, the honest answer is "upgrade Twig instead."
To executives: This is a small, MIT-licensed Twig extension that makes templates more expressive — authors can filter, map, and total collections directly instead of requesting new endpoints. It is cheap to try and cheap to remove. The caveat is maturity: 45 stars, one maintainer, last release in 2018, so it should be treated as an optional convenience rather than a platform dependency. Recommended posture: evaluate as a scoped experiment, not a standards decision.
To engineering: It buys us arrow functions and lambda-driven filters on Twig versions that lack them natively. If we're on Twig 3.x, the value proposition mostly evaporates and the correct move is upgrading Twig. If we're pinned to an older Twig and have recurring collection-transform templates, this removes duplication and nested-loop workarounds. We should isolate it behind a Twig extension registration and a config flag, keep it out of any launch-critical path, and be prepared to vendor or fork given the release history.
To design/content stakeholders: It expands what's expressible in templates — useful if we want theme or template authors to build richer list and summary views without engineering tickets. It does not change the authoring UI, and it will not make complex business rules safe to express in templates; those still route through engineering.
Recommendation: Adopt only as a contained, reversible capability gated on a Twig-version check; otherwise prioritize a Twig upgrade, which delivers the same outcome with a maintained dependency.
How can I help you explore Laravel packages today?