繁体   English   中英

laravel 5.3如何使用功能在视图中呈现页面的html内容

[英]laravel 5.3 how to render html content of a page in a view with a function

我正面临渲染问题...在我的product.blade.php中,我想在页面的一部分中显示来自没有iframe的外部源的html内容。 我想打个电话:

{!! View::make('pages.viewer', ['docUrl' => url('get-DocHtml/' . $primaryAttachment->id)]) !!}

在我的路线上:

Route::get('get-DocHtml/{id}', 'PagesController@getDocHtml');

在PagesController.php中:

public function getDocHtml($id){ 
$attachment = Attachment::find($id);
$filepath = Storage::disk('S3')->url($attachment->filename.'/test.html');
return \Response::make(file_get_contents($filePath), 200, [ 'Content-Type' => 'text/html; charset=utf-8' ]); 
}

我不知道如何像在所有功能上一样在viewer.blade.php或直接在我的product.blade.php中渲染它,并将其直接渲染...

有人知道如何渲染(没有帮助者)吗?

谢谢你的帮助。

你为什么不通过

file_get_contents($filePath)

作为变量查看?

您的方法getDocHtml应该以这种方式返回视图:

return view('viewer')->with([
    'external' => file_get_contents($filePath)
]);

然后,您可以通过传递的$external变量执行任何操作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM