How to render a blade template from filter function

@pascallaliberte Maybe this answer to an infinite-scroll topic might help?

Another route is to use the @inject directive to inject your service into the Blade view. This directive does not work for Sage9 because the directive looks for the app() helper from Laravel. You will need to overwrite it via setup.php like this:

/**
     * Overwrite @inject() Blade directive
     * IMPORTANT: This needs to follow the binding of the Blade Provider above.
     */
    sage('blade')->compiler()->directive('inject', function($expression) {
        $segments = explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression));
        $variable = trim($segments[0]);
        $service = trim($segments[1]);
        return "<?php \${$variable} = App\sage('{$service}'); ?>";
    });
1 Like