phplaravellaravel-blade

How to get Blade template view as a raw HTML string?


I need the HTML of my Blade template as a string.

I'm going to use that HTML string to generate a PDF from it.

At the moment I have Blade streaming as a response back to browsers.

 return view('users.edit', compact('user'));

How can I get the raw HTML string from the blade template?


Solution

  • You can call render() on the view.

    $html = view('users.edit', compact('user'))->render();
    

    See the View source code for more information.