aaronadal/twig-list-loop
Twig extension that adds a “list” tag to build reusable list/table/grid skeletons. Render items into a shared template via “using”, with access to loop plus list/else variables and optional inline if filters, similar to Twig’s for loop.
Pros:
Cons:
crabbly/laravel-twig).crabbly/laravel-twig) and potential refactoring of Blade templates to Twig.{{ item | raw }} may behave differently with auto-escaping).list tags, circular references).{% cache %}), or is runtime rendering acceptable?list tags (risk of stack overflow)?@component directives, custom Blade loops)?crabbly/laravel-twig and template conversion).crabbly/laravel-twig and configure Twig as a fallback or primary engine.config/twig.php:
'paths' => [
resource_path('views/vendor/twig'),
// Override Blade views if migrating
],
{# Before: Blade #}
@foreach($teachers as $teacher)
<tr><td>{{ $teacher->name }}</td></tr>
@endforeach
{# After: Twig List Loop #}
{% list teacher in teachers using 'table.tpl.twig' %}
<tr><td>{{ teacher.name }}</td></tr>
{% endlist %}
resources/views/vendor/twig/skeletons/table.tpl.twig) for consistency.headers, classes) for team adoption.{{ include('twig-component.twig') }}.{{ item | raw }} (auto-escaping changes).loop variable behavior (e.g., loop.index0 vs. loop.index).$teachers->toArray()).toArray() or custom accessors to avoid Twig’s object handling quirks.args.crabbly/laravel-twig.table.tpl.twig, card-grid.tpl.twig).{% list %} tags.{% list user in users.inexistent_property %}
→ Throws a Twig ErrorRuntimeException, not a Laravel BindingResolutionException.{% list %} in a try-catch (Twig) or validate data in PHP.{% extends %}, {% block %} for skeletons).{% list %} tags may increase memory usage if overused (e.g., nested loops).{% cache %} for static skeletons.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Twig template not found | White screen (500) | Validate skeleton paths in PHP |
How can I help you explore Laravel packages today?