php 如何将 Blade 模板视图作为原始 HTML 字符串获取?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50938285/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:50:51 来源:igfitidea点击:
How to get Blade template view as a raw HTML string?
提问by Yevgeniy Afanasyev
I need the HTML of my Blade template as a string.
我需要我的 Blade 模板的 HTML 作为字符串。
I'm going to use that HTML string to generate a PDF from it.
我将使用该 HTML 字符串从中生成 PDF。
At the moment I have Blade streaming as a response back to browsers.
目前,我将 Blade 流式传输作为对浏览器的响应。
return view('users.edit', compact('user'));
How can I get the raw HTML string from the blade template?
如何从刀片模板中获取原始 HTML 字符串?
回答by fubar
回答by Amina Darwish
<!-- View stored in resources/views/greeting.blade.php -->
<html>
<body>
<h1>Hello, {{ $name }}</h1>
</body>
</html>
<!-- In your php controller -->
return view('greeting', ['name' => 'James']);