Framework: Getting error using condition directives on blade components.

Created on 20 Mar 2020  路  3Comments  路  Source: laravel/framework

  • Laravel Version: 7.2.1
  • PHP Version: 7.4.3
  • Database Driver & Version: -

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 file

Steps To Reproduce:

<!--component-a.blade.php-->
<div {!! $attributes !!}></div>
<!-- main view file -->
<x-component-a @if(true) property @endif />
needs more info

All 3 comments

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
Was this page helpful?
0 / 5 - 0 ratings