Skip to content

Instantly share code, notes, and snippets.

@MrPunyapal
Last active January 17, 2024 16:04
Show Gist options
  • Save MrPunyapal/e54efa4ea5a67d73c2fbad202659234b to your computer and use it in GitHub Desktop.
Save MrPunyapal/e54efa4ea5a67d73c2fbad202659234b to your computer and use it in GitHub Desktop.
Solution to pesky @teleport glitch during compilation!

Teleport diractive issue

If you encounter caching issues with your @teleport Livewire/Blade directive after running php artisan view:cache, you may notice problems appearing instead of the expected compilation.

image

To resolve this issue, manually add compilation to the Blade directive.

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        app('blade.compiler')->directive('teleport', function ($expression) {
            return "<template x-teleport='<?php echo e($expression); ?>'>";
        });

        app('blade.compiler')->directive('endteleport', function () {
            return "</template>";
        });
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment