我使用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