Skip to content

The directive is not compatible with Blade::stringable #7

@machacekmartin

Description

@machacekmartin

Custom scope directive works as intended until we add our custom configuration of Blade::stringable into AppServiceProvider.

Steps to reproduce

  • Install this package
  • Use the example from the docs
    index.blade.php
@component('components.list', ['objects' => $objects])
    @scopedslot('item', ($object))
        <li>
            {{ $object->name }} 
            @if($object->isEditable)
                <a href="{{ route('objects.edit', $object->id) }}">{{ __('Edit') }}</a>
            @endif
        </li>
    @endscopedslot
@endcomponent

components/list.blade.php

<ul>
    @foreach($objects as $object)
        {{ $item($object) }}
    @endforeach
</ul>
  • No problems so far
  • Register Blade::stringable into your AppServiceProvider using boot method
public function boot(): void
{
    Blade::stringable(function(\Illuminate\Support\Carbon $value) {
        return $value->format('d. m. Y');
    });
}
  • Run php artisan optimize:clear
  • Page now no longer works and an exception is thrown.
Internal Server Error

ErrorException
Undefined variable $__bladeCompiler

I have not found any solution to this problem. Please let me know if you manage to fix it. I want to apply default formatting of dates in blade components, but it seems the custom scope directive is somehow conflicting with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions