djmzfKnm
djmzfKnm

Reputation: 27185

Laravel: how to add continue blade syntax inside HTML attributes without space

In laravel 5.4, how we can write the following:

<li class="page-item {{ ($paginator->onFirstPage() ? 'disabled' : '') }}">

Above is not working, and it shows output as

<li class="page-itemdisabled"> - If condition is true and

<li class="page-item "> - If condition is false.

Notice an space after page-item class. I don't want that.

To fix that, I simply tried:

<li class="page-item{{ ($paginator->onFirstPage() ? 'disabled' : '') }}">

But the above not working when condition is true and generates output as below:

<li class="page-itemdisabled">

Please advise how I can fix this, checked Laravel docs + Googled, but not finding anything such.

Upvotes: 0

Views: 410

Answers (4)

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

You should update your code like:

<li class="page-item {{isset($paginator->onFirstPage()) ? 'disabled' : ''}}">

Upvotes: 1

Nauman Zafar
Nauman Zafar

Reputation: 1103

Just add a space before disabled. Notice the added space below.

<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">

Upvotes: 2

Gabriel Caruso
Gabriel Caruso

Reputation: 869

Intead of 'disabled' use ' disabled':

<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">

Upvotes: 1

Vishal Varshney
Vishal Varshney

Reputation: 905

you can write

<li class="page-item{{ ($paginator->onFirstPage() ? 'disabled' : '') }}">

to

<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">

Upvotes: 1

Related Questions