@php
$name = $data['componentName'];
$attributes = collect($data['attributes'])->filter(fn (mixed $value, string $key) => ! is_array($value));
$personalize = $data['attributes']['personalize'] ?? [];
$ignores = ['slot', 'trigger', 'content', 'componentName'];
// Although we can use a single filter here, it was
// preferable to do it this way to increase readability.
$properties = collect($data)
->filter(fn (mixed $value, string $key) => ! is_array($value))
->filter(fn (mixed $value, string $key) => ! is_callable($value))
->filter(fn (mixed $value, string $key) => ! in_array($key, $ignores));
@endphp
{{ $name }}
@forelse ($properties as $key => $value)
- {{ $key }}: {{ $value }}
@if ($loop->last && $data['slot']->isNotEmpty())
- slot mode:
@endif
@empty
No attributes
@endforelse
@if ($attributes->isNotEmpty())
Attributes
@foreach ($attributes as $key => $value)
- {{ $key }}: {{ $value }}
@endforeach
@endif
@if (!empty($personalize))
Scoped Personalization
@foreach ($personalize as $key => $value)
{{-- Block Name --}}
- {{ $key }}:
@if (is_array($value))
@foreach ($value as $helper => $content)
{{-- Replace & Remove --}}
@if (is_array($content))
- {{ $helper }}:
@foreach ($content as $from => $to)
- "{{ $from }}": "{{ $to }}"
@endforeach
@else
{{-- Remove (When Strings), Append & Prepend --}}
- {{ $helper }}: "{{ $content }}"
@endif
@endforeach
@else
- {{ $value }}
@endif
@endforeach
@endif