sprintcar78a
sprintcar78a

Reputation: 199

laravel breadcrumbs not rendering html in Laravel 5.4

Within a Layout

@section('breadcrumbs', Breadcrumbs::render('messages'))
@section('content')
@include('layouts.breadcrumbs')

breadcrumbs.blade.php

<div class="fluid-container">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                @yield('breadcrumbs')
            </div>
        </div>
    </div>
</div>

Standard BS3 view with DaveJamesMillar Breadcrumbs

@if ($breadcrumbs)
    <ol class="breadcrumb">
        @foreach ($breadcrumbs as $breadcrumb)
            @if ($breadcrumb->url && !$breadcrumb->last)
                <li><a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a></li>
            @else
                <li class="active">{{ $breadcrumb->title }}</li>
            @endif
        @endforeach
    </ol>
@endif

Appeared to be working fine until upgrading to L5.4, now rather than displaying the breadcrumbs it displays non-processed HTML

<ol class="breadcrumb"> <li><a href="http://www.linkremoved">Home</a></li> <li> class="active">Messages</li></ol>

After reading the latest docs for davejamesmillar laravel-breadcrumbs with support for L5.4 https://media.readthedocs.org/pdf/laravel-breadcrumbs/latest/laravel-breadcrumbs.pdf with reference to 1.4.2 using Blade Sections nothing appears to have changed in the way this needs to be coded. Unsure why the HTML is not being processed to display as a link.

Upvotes: 2

Views: 1007

Answers (1)

sprintcar78a
sprintcar78a

Reputation: 199

RAR, hours later! Appears Laravel 5.4 runs a htmlentities when injecting a variable into a @section

I changed

@section('breadcrumbs', Breadcrumbs::render('messages'))

to

@section('breadcrumbs') {!! Breadcrumbs::Render('messages') !!} @endsection

And the html is now being processed and displayed as it should.

Upvotes: 2

Related Questions