Laravel 9内联刀片模板渲染;渲染常数而不是变量
Laravel 9中有一项新功能,可以允许内联刀片模板施用。链接: https://laravel.com/docs/9。 x/blade#渲染inline-inline-blade-templates
假设我想从数据库中渲染的数据库中存储一个值(作为电子邮件的正义)。
例如 < p>亲爱的{{$ first_name}}} {{$ last_name}}</p>
我将使用此;
Blade :: Render($ body,['first_name'=> $ first_name,'last_name'=> $ last_name]));
,
我可以输出类似的内容;
亲爱的John Doe
在发送电子邮件的正文中。
但是,如果我想使用该怎么办 < p>亲爱的{{first_name}} {{last_name}}</p>
在我的电子邮件模板中存储在数据库中(没有美元符号,使其成为常数而不是可变的)。如何使用Blade :: Render()渲染这个常数?
There is a new feature in Laravel 9 that allows inline blade template rending. Link: https://laravel.com/docs/9.x/blade#rendering-inline-blade-templates
Let’s say I have a value stored in the database (as the body of the email) I want to render from database as email.
E.g<p> Dear {{$first_name}} {{$last_name}} </p>
I would use this;
Blade::render($body, [‘first_name’ => $first_name, ‘last_name’ => $last_name]);
With this I’m able to output something like;
Dear John Doe
In the body of the email sent.
However, what if I want to use<p> Dear {{first_name}} {{last_name}} </p>
in my email template stored in the database (without the dollar sign, making it a constant rather than a variable). How can I render this constant using the Blade::render()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,在将输出发送到刀片之前,您必须操纵模板。
拉维尔(Laravel)有许多助手可以做这样的事情。
上面的代码将完成这项工作。
I think you will have to manipulate the templates, before sending output to blade.
Laravel has many helpers to do things like that.
Above code will do the job.