PeterF's avatar

syntax error, unexpected token "<"

I have some simple html in a component which looks like this,

<div role="tabpanels" class="mb-2 bg-white border border-blue-700 rounded-b-md">
	@foreach ($trade->executions as $execution)
		<livewire:trade.execution-tab-form :executionId='{{ $execution->id }}' />
	@endforeach
</div>

It seems fine to me, I even dd the $trade before the render is called in the livewire component and its got all the bits it should have in all the right places.... so I am kind of stuck... what have I done?

0 likes
10 replies
Sinnbeck's avatar

Where does it say the unexpected token is?

Does it work if you replace <livewire:trade.execution-tab-form :executionId='{{ $execution->id }}' />with {{execution->id}}

PeterF's avatar

@Sinnbeck It is the livewire call that generates the error... and yes, if I replace it with just the {{$execution_id}} there is no error......

PeterF's avatar

@Sinnbeck That is a pile of boring HTML in a section element that starts like this....

<section x-show="isSelected($id('tab', whichChild($el, $el.parentElement)))"
    :aria-labelledby="$id('tab', whichChild($el, $el.parentElement))" role="tabpanel" class="p-8" wire:key="tab-section">
Sinnbeck's avatar

@PeterF You are not closing it?

<section x-show="isSelected($id('tab', whichChild($el, $el.parentElement)))"
    :aria-labelledby="$id('tab', whichChild($el, $el.parentElement))" role="tabpanel" class="p-8" wire:key="tab-section">
</section> //added
PeterF's avatar

@Sinnbeck nah... thats not it... I just snipped for readability.... its closed and there are a stack of blocks inside that have nothing exciting... no livewire or alpine or anything...

Sinnbeck's avatar

@PeterF Well you seem to have an extra < somewhere. And removing that component removes the error, to that component must have something to do with the error.

Snapey's avatar

The "unexpected token" must be in php not your html

Livewire can confuse error reporting , falsely showing the view as the issue, so I would look in your component code.

1 like
PeterF's avatar
PeterF
OP
Best Answer
Level 6

I have refactored the original call to the livewire component, and passed the whole object instead of the id of the object, and it's all working now, so there was some weird error I guess, in the mount command somewhere.... thanks for your help @sinnbeck and @snapey

1 like
Piracemma's avatar

I was having the same problem and what solved it was removing the "{{ }}" because the ":" already indicates that it is a php code

2 likes

Please or to participate in this conversation.