Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a blade file to HTML and save it?

For example, there is a file \resources\views\test.blade.php

@extends('layouts.app')

@section('content')
   <div class="container">
      {{ $article->content }}
   </div>
@endsection

I want to save it as \resources\views\html\test.html. What should I do?

like image 945
zwl1619 Avatar asked Aug 17 '17 14:08

zwl1619


1 Answers

I would try something like this, although I haven't test it my self:

File::put('test.html',
    view('resources.views.test')
        ->with(["article" => $article])
        ->render()
);
like image 58
Asur Avatar answered Nov 18 '22 07:11

Asur