Inside of my markdown email template, I am wrapping a button component inside of an @if
statement.
When doing so, the button is rendering the raw HTML inside of the email and not the actual button.
@component('mail::message')
# Hello, {{ $user->forename }}
{{ $email->body }}
@if($email->responsable)
@component('mail::button', ['url' => route('responses.create', $email)])
Submit Response
@endcomponent
@endif
@endcomponent
Here's what the email is rendering...
But, if I take the button component outside of the if statement as shown above, the button is correctly rendered.
Here's how it looks without the if statement...
I've been searching around and asked on Larachat etc. but cannot find out why this happening.
Seems related to #17333 but republishing mail files does not resolve my issue using:
php artisan vendor:publish --tag=laravel-mail
Upgraded to Laravel v5.4.36 too, still occurring. Not ready to upgrade to 5.5 yet, unless there is a fix available in 5.5 then I will have to.
Just to clarify; your first image isn't the view of the source, but an image of the actual rendered content? As in; it is shown as source code, and not rendered html in your mail?
Yes that鈥檚 correct, the actual source is the button wrapped in code and pre tags? Which is why I assume it shown in the rendered email.
Hi @JoeDawson
I was able to recreate your issue and this worked out for me:
@component('mail::message')
# Hello, {{ $user->forename }}
{{ $email->body }}
@if($email->responsable)
@component('mail::button', ['url' => route('responses.create', $email)])
Submit Response
@endcomponent
@endif
@endcomponent
Let me know if it worked out for you. (Notice the indentation)
Hey @Pauly-,
That worked! I assume because my template is markdown it's parsing the indentation is a code block, rather than me trying to keep my code readable lol.
And I guess it's also nothing directly related to my if statement, just a matter of how it's indented. Regardless of the directive used.
Appreciate the help.
@JoeDawson
Yes, I bet your assumptions are correct.
No problem.
Don't use indentation in your markdown templates.
@pactode
That's Worked. Thank You.
Most helpful comment
Don't use indentation in your markdown templates.