Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel- use @foreach in markdown mail

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.

like image 280
Ajith S Avatar asked Jan 31 '18 08:01

Ajith S


1 Answers

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>
like image 72
Ben Avatar answered Oct 07 '22 02:10

Ben