Laravel 5.7 通知 -> 行没有转义选项 html 但它在 5.5 中工作
Laravel 5.7 Notification ->line there is no option to escape html but it was working in 5.5
我在 Laravel 5.5 和 5.7 中有相同的代码通知,对于 Laravel 5.5,我可以在 -> 行中使用 <strong>
,但在 5.7 中它会转义它。
在我的通知 blade 查看文件中,我设置了 {{ ]} 或 {!! !!},我仍然无法在我的电子邮件中显示 html。在 5.5 中,我不需要转义它仍然有效。
\this is when I not escape
<strong>2019-01-13 15:41</strong>
\this is when I escape
<strong>2019-01-13 15:37</strong>
我想要的是像下面这样显示粗体。
2019-01-13 15:37
这两种方法都显示了标签,它不会加粗文本。相同的编码在 5.5 中有效,但在 Laravel 版本 5.7.20
中无效
从 5.5 升级到 5.6,删除了 Laravel blade 双编码。如果你想保持以前的防止双重编码的行为,你可以使用像下面这样的 Blade::withoutDoubleEncoding
方法。
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Blade::withoutDoubleEncoding();
}
}
您可以在 Laravel Documentation 上阅读更多相关信息。
根据@driesvints
You don't need withoutDoubleEncoding in 5.7 so you can remove that.
As you can see lines are being escaped in the template:
framework/src/Illuminate/Notifications/resources/views/email.blade.php
Line 15 in d818fd1
{{ $line }} So you'll need to indicate that the line has HTML in it.
Try this:
->line(new HtmlString('Due Date: ' . Carbon::parse($this->info->created_at)->format('Y-m-d
H:i').''));
这是解决方案。谢谢!
我在 Laravel 5.5 和 5.7 中有相同的代码通知,对于 Laravel 5.5,我可以在 -> 行中使用 <strong>
,但在 5.7 中它会转义它。
在我的通知 blade 查看文件中,我设置了 {{ ]} 或 {!! !!},我仍然无法在我的电子邮件中显示 html。在 5.5 中,我不需要转义它仍然有效。
\this is when I not escape
<strong>2019-01-13 15:41</strong>
\this is when I escape
<strong>2019-01-13 15:37</strong>
我想要的是像下面这样显示粗体。
2019-01-13 15:37
这两种方法都显示了标签,它不会加粗文本。相同的编码在 5.5 中有效,但在 Laravel 版本 5.7.20
中无效从 5.5 升级到 5.6,删除了 Laravel blade 双编码。如果你想保持以前的防止双重编码的行为,你可以使用像下面这样的 Blade::withoutDoubleEncoding
方法。
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Blade::withoutDoubleEncoding();
}
}
您可以在 Laravel Documentation 上阅读更多相关信息。
根据@driesvints
You don't need withoutDoubleEncoding in 5.7 so you can remove that.
As you can see lines are being escaped in the template:
framework/src/Illuminate/Notifications/resources/views/email.blade.php
Line 15 in d818fd1
{{ $line }} So you'll need to indicate that the line has HTML in it. Try this:
->line(new HtmlString('Due Date: ' . Carbon::parse($this->info->created_at)->format('Y-m-d H:i').''));
这是解决方案。谢谢!