Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CarlEOgden's avatar

Displaying HTML text from a variable in a blade

Hi All

Hope everyone is okay and staying safe!

I've got a daily php cron routine that I'm writing, I've got all the data in my controller and when I then call the blade to create the view that will be emailled, I can't get v-html to display the variable as its coming from a php variable and not a javascript variable.

To call my blade I use:-

\Mail::send('emails.ml-email', compact('subject', 'email', 'email_body', 'agent', 'send_as_email'), function ($message) use ($email, $subject) 

In my blade, i've tried:

{{ $email_body }}

<div v-html="{{ $email_body }}"

but I either get:

<div>Email test</div>

or nothing or just the variable name!

Can anyone help me simply display the text held within $email_body a formatted html.

Thanks in advance for any and all help given Carl.

0 likes
2 replies
Ksandar's avatar
Ksandar
Best Answer
Level 26

@carleogden hi, try this in blade

{!! $email_body !!}

You can reed more about it here (see "Displaying Unescaped Data" section)

2 likes
CarlEOgden's avatar

Hi

That worked like a dream.

Thank you very much for advise.

Cheers Carl.

1 like

Please or to participate in this conversation.