jenssegers/blade

CUSTOM Directive Does NOT Work WITH PHP

mahmoudmohamedramadan opened this issue · 3 comments

When I run this code the custom directive does NOT rendered successfully

require_once dirname(__FILE__, 3) . '/vendor/autoload.php';

use Jenssegers\Blade\Blade;

$viewFolderPath = dirname(__FILE__, 3) . '/app/Blade/views';

$blade = new Blade($viewFolderPath, 'cache');

echo $blade->directive('php', function () {
    return "<?php echo 'Welcome; ?>'";
});

and inside home.blade.php

@php

BUT the output be @php NOT Welcome as expected

QWp6t commented

image

also when rendering, print out @custom

blade

xy2z commented

also when rendering, print out @custom

blade

I just tested the code and it works for me.

From the left picture it looks like you added the directive at the end of the index.php file, you have to make sure to add the directive before you make/render the views.