mikaelmattsson / blade

Blade for Wordpress
GNU General Public License v2.0
151 stars 21 forks source link

Allow .blade.php extension #21

Closed CupOfTea696 closed 9 years ago

CupOfTea696 commented 9 years ago

Hi, would it be possible to allow including files named .blade.php instead of just .php? Or is that not possible?

mikaelmattsson commented 9 years ago

Not as far as I know. The files need to follow the naming convention of the wordpress template hierarchy .

CupOfTea696 commented 9 years ago

Alright. That's a bit of a shame though.

younes0 commented 9 years ago

Any workaround?

mikaelmattsson commented 9 years ago

Create a hook that modifies how WordPress calculates which template to use. Not a very good Idea but it could work.

younes0 commented 9 years ago

That's what I had in mind I tried hooks like "index_loaded" without success

mikaelmattsson commented 9 years ago

Try template_redirect or template_include maybe? More can be found here

younes0 commented 9 years ago

works, but this code is specific to .blade.php, maybe BLADE_EXT should be an array containing (.blade.php, the official blade extension and .php)

public function template_include_blade( $template ) {

                /** ... **/

        Laravel\Blade::sharpen();

        $bladeName        = str_replace('.php', '.blade.php', $template);
        $bladeExtTemplate = locate_template([basename($bladeName)]);

        if (file_exists($bladeTemplate)) {
            $template = $bladeExtTemplate;
        }

        $view = Laravel\View::make( 'path: ' . $template, array() );
               /** ... **/
    }
younes0 commented 9 years ago

should I make a PR ?

mikaelmattsson commented 9 years ago

Can't hurt.