Is that possible to use laravel blade outside the view folder?

前端 未结 3 709
面向向阳花
面向向阳花 2021-02-06 13:42

I got a wordpress blog inside the public sub folder.

I wanted to use same layout with the laravel view that using blade.

Is there anyway to achieve that?

3条回答
  •  终归单人心
    2021-02-06 14:13

    I managed to do this with the following function:

    function bladeCompile ($from, $to, $data)
    {
        $fs = new \Illuminate\Filesystem\Filesystem;
        $b = new \Illuminate\View\Compilers\BladeCompiler($fs, __DIR__);
        $src = $b->compileString (file_get_contents($from));
    
        $isPhp = false;
        if (substr( $src, 0, 5 ) === "

    And then use with:

    $data = array ( // equivalent to the 'with' function.
        'parameter' => 'value';
        );
    bladeCompile ('input.blade.file', 'result.file', $data);
    

提交回复
热议问题