Michael Emerson
Michael Emerson

Reputation: 1813

Laravel blade template not rendering table properly

I'm quite new to Laravel, but have recently taken over a project from someone and trying to get the mail blade templates to render but I am having problems.

The code used for the enquiry email template is as follows:

@component('mail::message')
    #New customer enquiry

    We have received a new customer enquiry.

    @component('mail::table')
        | **Name**                                       | **Email**             | **Telephone**           |
        | ---------------------------------------------- |:---------------------:| -----------------------:|
        | {{$enquiry->firstname}} {{$enquiry->lastname}} | <{{$enquiry->email}}> | {{$enquiry->telephone}} |
    @endcomponent

    Thanks,<br>
    {{ config('app.name') }}
@endcomponent

But the table always renders as raw HTML, here is a screenshot of how the email looks in MailCatcher:

enter image description here

I've checked a couple of other posts that concern this kind of issue but usually it's due to the attempt to render more than one table in a mail template, but this is just a single table. Is there a component I have missed or is it just MailCatcher not rendering correctly?

Upvotes: 2

Views: 4798

Answers (2)

Chinonso Chukwuogor
Chinonso Chukwuogor

Reputation: 579

When using Markdown to render emails, avoid using indents excessively. Your code should look like this

@component('mail::message')
#New customer enquiry

We have received a new customer enquiry.

@component('mail::table')
| **Name**                                       | **Email**             | **Telephone**           |
| ---------------------------------------------- |:---------------------:| -----------------------:|
| {{$enquiry->firstname}} {{$enquiry->lastname}} | <{{$enquiry->email}}> | {{$enquiry->telephone}} |
@endcomponent

Thanks,<br>
{{ config('app.name') }}
@endcomponent

Upvotes: 14

Mkk
Mkk

Reputation: 443

You didn't show how the html which is not being rendered is being loaded. But it's possible you need to use {!! !!} instead of {{ }} for the variables that contain html.

Upvotes: 0

Related Questions