Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active August 29, 2024 14:48
Show Gist options
  • Save ziadoz/25eabc43b802d97211de82e3735362fb to your computer and use it in GitHub Desktop.
Save ziadoz/25eabc43b802d97211de82e3735362fb to your computer and use it in GitHub Desktop.
Laravel Blade Props
@php
$attr3 = 'baz';
$attr4 = 99_999;
$attr5 = new stdClass;
$attrWtf = 'wtf';
@endphp
<x-my-component
attr1="foo" {{-- Component receives string --}}
attr2="{{ 'bar' }}" {{-- Component receives string --}}
:attr3="$attr3" {{-- Component receives string --}}
:attr4="$attr4" {{-- Component receives int --}}
:attr5="$attr5" {{-- Component receives object --}}
attr6="{{ 10_000 }}" {{-- Component receives a string --}}
{{-- This syntax doesn't work --}}
{{-- :attrWtf="{{ $attrWtf }}" --}}
/>
@props(['attr1', 'attr2', 'attr3', 'attr4', 'attr5', 'attr6', 'attrWtf'])
@dump($attr1, $attr2, $attr3, $attr4, $attr5, $attr6, $attrWtf ?? null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment