如何在降价中插入换行符通知
问题描述:
我正在使用Laravel的Notifications系统在用户注册时发送欢迎邮件。一切都很好,除非我不能为我的生活弄清楚如何在问候中插入换行符。如何在降价中插入换行符通知
这是我的代码:
namespace App\Notifications\Auth;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class UserRegistered extends Notification
{
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Welcome to website!')
->greeting('Welcome '. $notifiable->name .'!')
->line('## Sub heading line')
->line('Paragraph line')
->markdown('mail.welcome');
}
}
我想在这里把休息->greeting('Welcome '. $notifiable->name .'!')
的欢迎和名之间。任何人都知道我可以做到这一点?我已经尝试了markdown文档中描述的双倍空间。我试过使用nl2br()
。我试过\ n。我试过<br>
。什么都没有
答
它可能看起来很糟糕,但我认为这可以工作:
->greeting("Welcome
". $notifiable->name ."!")
它应该保持换行符,不幸的是我不能测试它现在
编辑:另一种选择是使用不同的greeting
电话:
return (new MailMessage)
->subject('Welcome to website!')
->greeting('Welcome')
->greeting($notifiable->name .'!')
->line('## Sub heading line')
->line('Paragraph line')
->markdown('mail.welcome');
答
得到它的工作。原来是在使用{{ }}
时因Laravel转义HTML而出现的问题。你必须防止逃逸通过{!! !!}
:Using double curly brace in Laravel Collective
对于那些有兴趣我的问候语,现在->greeting('Welcome<br>'. $notifiable->name .'!')
,并在我的降价模板,它的
{{-- Greeting --}}
@if (! empty($greeting))
# {!! $greeting !!}
@endif
有你提到这个职位?
https://*.com/questions/26626256/how-to-insert-a-line-break-br-in-markdown –
是的。试过 –
@ james.brndwgn在你的双引号中使用
– shashi