我使用an emogrifier來格式化刀片模板的結果,以便我可以通過電子郵件發送它。乾淨地emogrify Laravel刀片模板文件的最佳方法是什麼?
$html = View::make('emails.notification', [
'data' => $data
]);
$emogrifier = new Emogrifier($html, null);
$result = $emogrifier->emogrify();
// now I can send the result in an email...
可正常工作,但在乾淨的代碼和可測試性的興趣,我想延長我的刀模板,模板本身emogrify HTML。事情是這樣的:
@emogrify
<style>
.red-text {
color: red;
}
</style>
<p class="red-text">This text is red</p>
@endemogrify
...但它看起來像刀片指令不允許打開/關閉標籤這樣的。有沒有更好的方法來完成這一點?
如果你發現任何有趣的解決方案我很感興趣。 – AsTeR
@AsTeR我從來沒有找到一個優雅的解決方案。我只是在刀片模板外面模糊了。 – Divey
我最終也這樣做了! – AsTeR