I am trying to use @foreach
loop inside markdown template for sending mails.
While using HTML tags inside @foreach, it is not rendered properly
@component('mail::message')
These are the latest contents in our website
@foreach($results as $type => $result)
<h4>{{ $result['name'] }}</h4>
@endforeach
Thanks,<br>
{{ config('app.name') }}
@endcomponent
In the received mail, the <h4>
tag will be displayed as,
<h4>Article</h4>
Markdown is not getting processed when it's placed inside @foreach
loop. But it's processed when placed outside @foreach
loop.
Any help will be much appreciated. Thanks.
As stated in laravel documentation:
Do not use excess indentation when writing Markdown emails. Markdown parsers will render indented content as code blocks.
The problem is not the HTML tags put inside the @foreach
, but the indentation makes parsers render as follows (I am using markdown now, 4 spaces before <h4>
):
<h4>Article</h4>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With