簡體   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