laravel 5.3 如何在具有函数的视图中呈现 html 页面内容

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

我遇到了渲染问题...在我的 product.blade.php 中,我想在页面的一部分中显示来自外部源的 html 内容,而不使用 iframe。我想拨打这样的电话:

{!! 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 以这种方式查看:

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

然后你可以用传递的 $external 变量做任何事情