- Can I use this package with Laravel Blade templates?
- No, this package is Twig-only. If you’re using Blade, you’ll need to integrate Twig (e.g., via `crabbly/laravel-twig`) and migrate those templates to Twig first. It’s not designed for hybrid Blade-Twig workflows.
- What Laravel versions does this package support?
- The package itself doesn’t enforce Laravel version constraints, but it requires Twig (last updated in 2019), which may conflict with modern Laravel (9.x+) or PHP 8.1+. Test thoroughly for compatibility.
- How do I install and configure this in Laravel?
- Run `composer require aaronadal/twig-list-loop`, then register the Twig extension in your Twig environment (e.g., via `crabbly/laravel-twig`). No additional Laravel service provider is needed—it’s purely a Twig extension.
- Will this work with Laravel Livewire or Alpine.js for dynamic updates?
- Yes, but ensure your Twig templates are properly integrated with Livewire/Alpine. The package handles rendering logic; dynamic behavior (e.g., AJAX updates) depends on your frontend setup. Test edge cases like nested loops.
- Are there performance concerns with nested list tags?
- Nested tags may introduce rendering overhead, especially with complex skeletons. Avoid excessive nesting (e.g., >3 levels) to prevent stack overflows. Cache skeletons with Twig’s `{% cache %}` if performance is critical.
- How does this compare to Blade’s `@component` directives?
- This package offers Twig-specific syntax for reusable lists/tables, while Blade’s `@component` is more generic. If you’re migrating from Blade, `@component` might feel more familiar, but this package excels for Twig-centric apps with repetitive table/grid structures.
- Does this support Laravel Eloquent models or Collections?
- No, it works with raw data passed to Twig. You’ll need to pre-process Eloquent models/Collections into arrays or objects before passing them to the `list` tag. Example: `{% list user in users|keys %}`.
- How do I handle empty lists or fallback content?
- Use the `else` variable in your skeleton template. The package passes rendered `else` content to the `else` variable, letting you conditionally display placeholders (e.g., `<p>No records found</p>`).
- Is this package actively maintained? What if Twig v3+ breaks compatibility?
- The package hasn’t been updated since 2019, so Twig v3+ or PHP 8.1+ may introduce issues. Check the GitHub issues for open compatibility reports. Consider forking or alternatives if maintenance is a concern.
- Can I use this for public-facing grids (e.g., DataTables integration)?
- Yes, but ensure your skeleton template supports client-side libraries like DataTables. The package handles server-side rendering; client-side interactivity (e.g., sorting, pagination) must be implemented separately via JavaScript.