Reputation: 35400
This may sound trivial but I haven't found a related post.
How do I avoid generation of line breaks in Blade template output? e.g. the following loop spits out one option per line (physical line break after each iteration, not <br>
):
[
@foreach ($Collection as $row)
"{{ $row->Abbreviation }}"{{ ($loop->last? '' : ',') }}
@endforeach
]
I would expect it to generate something like:
["Option 1","Option 2", "Option 3"]
Instead it generates this:
[
"Option 1",
"Option 2",
"Option 3"
]
And while this works, I want my output to be more tidy. Is there a way to ask Blade engine not to add line breaks?
I'm using Laravel 5.6.
Upvotes: 0
Views: 592
Reputation: 659
Just do it in one line only.
[@foreach ($Collection as $row) "{{ $row->Abbreviation }}"{{ ($loop->last? '' : ',') }}@endforeach]
it will generate an output like this
["Option 1","Option 2", "Option 3"]
Upvotes: 1