mercredi 15 février 2017

What is the best way to cleanly emogrify a Laravel blade template file?

I'm using an emogrifier to format the results of a blade template so I can send it in an email.

$html = View::make('emails.notification', [
    'data' => $data
]);

$emogrifier = new Emogrifier($html, null);

$result = $emogrifier->emogrify();

// now I can send the result in an email...

This works as expected, but in the interest of clean code and testability, I would like to extend my blade template to emogrify HTML within the template itself. Something like this:

@emogrify
  <style>
    .red-text {
      color: red;
    }
  </style>
  <p class="red-text">This text is red</p>
@endemogrify

...but it looks like Blade directives don't allow opening/closing tags like this. Is there a better way to accomplish this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lLdt1W
via IFTTT

Aucun commentaire:

Enregistrer un commentaire