wenzzzel
wenzzzel

Reputation: 682

Font awesome not working in loop/from variable?

I'm using Laravel 5.7 and just got font awesome to work when putting icons staticly into my page, but when they're fetched there from an object they don't seem to work.

This is my index page:

@extends('layouts.app')
@section('content')
    {{$data['hosts'][0]->icon}}
    <br>
    <i class="far fa-question-circle"></i>
@endsection


It displays like this:

enter image description here

Am I doing something wrong?

Upvotes: 0

Views: 171

Answers (2)

danboh
danboh

Reputation: 778

I think your code is being escaped. As per Laravel's documentation, try using {!! !!} like:

@extends('layouts.app')
@section('content')
    {!! $data['hosts'][0]->icon !!}
    <br>
    <i class="far fa-question-circle"></i>
@endsection

Upvotes: 2

Mihir Bhende
Mihir Bhende

Reputation: 9045

You are outputting HTML from the icon property, use this instead :

{!! data['hosts'][0]->icon !!}

{{ .. }} will treat everything inside it as string.

Upvotes: 1

Related Questions