Ricardo Alves
Ricardo Alves

Reputation: 1121

Laravel Pass Variable with HTML content to Email View

I think I'm doing something worng.

I'm trying to pass a variable into an Email View. This varaibvle is read from the database and is configurable via administration page. For some reason, I'm getting the emails without the HTML paser (I see tags like in them) I wanted them to be parsed, so my client can manually change them everytime he wants.

How is that achievable?

My code is:

 Mail::send('emails.contact', array(
        'name' => $request->get('name'),
        'email' => $request->get('email'),
        'user_message' => $request->get('message'),
        'email_content' => html_entity_decode($emailContent->Description)
    ), function($message) use ($result)
    {
        $message->from(env('MAIL_USERNAME'));
        $message->to($result['From'], $result['Name']);
        $message->subject('[Casa Bordeira] We received your message');
    });

An in the view:

<div class="contentEditableContainer contentTextEditable">
  <div class="contentEditable" align='left' >
    <p>
        Hello <strong>{{$name}}</strong>. 
        <br/>
        {{$email_content}}
        <br/>
        <br/>
        <br/>
        Here's a copy of your message:
        <br/>
        <br/>
        {{$user_message}}
    </p>
  </div>
</div>

Upvotes: 2

Views: 3460

Answers (1)

fubar
fubar

Reputation: 17388

Blade has two different tag styles.

  1. {{ $string }} - this will escape the content using HTML entities.

  2. {!! $string !!} - this does not escape the content and will output the raw HTML value.

See the docs for more information.

Upvotes: 6

Related Questions