- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 an emogrifier格式化 Blade 模板的结果,以便我可以通过电子邮件发送它。
$html = View::make('emails.notification', [
'data' => $data
]);
$emogrifier = new Emogrifier($html, null);
$result = $emogrifier->emogrify();
// now I can send the result in an email...
这按预期工作,但为了干净的代码和可测试性,我想扩展我的 Blade 模板以在模板本身内 emogrify HTML。像这样:
@emogrify
<style>
.red-text {
color: red;
}
</style>
<p class="red-text">This text is red</p>
@endemogrify
...但看起来 Blade 指令不允许像这样打开/关闭标签。有没有更好的方法来完成这个?
最佳答案
这是我在 laravel 中制作电子邮件 Blade 的方法(我通常不使用 emogrifier,但希望这对您有所帮助):
Create a base email blade (usually in resources/views/emails/email.blade.php):
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<style>
/* Include styles for all emails here */
</style>
@section('head')
@show
</head>
<body>
<div class="email-body">
@section('body')
@show
</div>
</body>
</html>
然后,当我想创建电子邮件时,我会展开 Blade :
Create a new file in resources/views/emails/new-user-email.blade.php:
@extends('emails.email')
@section('head')
<style>
/* Add additional styling here if you need to! */
</style>
@stop
@section('body')
<!-- Email body content here! -->
<h1>Welcome new user!</h1>
@stop
关于php - 干净地 emogrify Laravel Blade 模板文件的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42254346/
我正在使用 an emogrifier格式化 Blade 模板的结果,以便我可以通过电子邮件发送它。 $html = View::make('emails.notification', [ '
我一直在搜索有关如何使用 Emogrifier 的信息将带有 CSSv3 链接的 HTML 转换为内联 HTML 格式。到目前为止,我一直在寻找与向不允许 CSS 的网站发送电子邮件有关的信息。 关于
我目前正在设置一个包含两部分的电子邮件模板:HTML 和 CSS。为了将所有内容放在一起并将 HTML 与 CSS 合并,我使用了 PHP Emogrifier。 现在我发现当我对这两个元素进行 em
Fatal error: Call to undefined function mb_convert_encoding() in /home/abcdef/public_html/folder_nam
我是一名优秀的程序员,十分优秀!