Closed mojtabaahn closed 4 years ago
I see you're using 7.0.2, can you upgrade to the very latest version? Numerous fixes have been made since.
Thanks for feedback. Upgraded to 7.2.1 and same results appear.
Unfortunately we don't seem to support this syntax. Please try:
@if(true)
<x-component-a property />
@else
<x-component-a />
@endif
Unfortunately we don't seem to support this syntax. Please try:
@if(true) <x-component-a property /> @else <x-component-a /> @endif
My card component expects a lot of markup in its $slot. It seems I would have to write a lot of code twice with this solution.
I hate to say this without providing ant solutions or suggestions, but I have the same problem. Is there any other elegant way to handle this?
I hate to say this without providing ant solutions or suggestions, but I have the same problem. Is there any other elegant way to handle this?
15 min later, I solved this (in my usecase)
input-component.blade.php
<input type="checkbox" id="{{ $name }}" name="{{ $name }}" {{ $attributes->merge(['class' => $makeItemClass($errors->first($name))]) }}
@if($isChecked) checked @endif <--- added a flag here
/>
InputComponent.php
class InputSwitch extends InputGroupComponent
{
public $isChecked;
public function __construct( $isChecked = false) {
$this->isChecked = $isChecked;
}
}
Usage in my view
<x-admin.input-switch name="is_active" label="{{ __('Active') }}" label-class="text-dark" top-class="col-2" :is-checked="true">
</x-admin.input-switch>
Cheers :wine_glass:
No there isn't unfortunately. This is pretty hard to make possible with the compiler. If anyone can figure out on how to make directives in components possible we're welcoming PRs.
Description:
Imagine we have blade component
component-a
and we want to pass some attribute to it on some condition ( well, if condition did not met, we want to pass nothing ).Currently when using condition directives (
@if
,@isset
, ...) it will make error : syntax error, unexpected 'endif' (T_ENDIF), expecting end of fileSteps To Reproduce: