Skip to content

A Blade templating language adaptation for the Viper Framework

License

Notifications You must be signed in to change notification settings

arsengoian/viper-blade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blade for Viper Framework

A Blade templating language adaptation for the Viper Framework

For Blade doc, refer to the official Laravel documentation on Blade

Usage

May be used from the controller like this:

namespace App\Controllers;

use Viper\Core\Routing\Controller;
use Viper\Core\Routing\Methods\GET;
use Viper\Core\Viewable;
use Blade\View;
use App\Models\Client;

class HomeController extends Controller implements GET
{

    public function get (...$args): ?Viewable
    {
        $clients = Client::all();
        return new BladeView('test', [
            'folks' => $clients,
        ]);
    }

}

Exception reporting

Exceptions may be parsed nicely in a custom view. By default, the error.blade.php is invoked with $e variable for exception

use \Blade\View::bindErrorView() for configuration

Setup

Extra variables and error preferences may be passed from a filter (official doc on filters):

namespace App\Filters;

use Blade\View;
use Viper\Core\Filter;

class BladeFilter extends Filter
{

    public function proceed ()
    {
        // Set up custom error reporting
        if (!Config::get('DEBUG'))
            View::bindErrorView('publicErrorView', 'exception');
        
        // These variables will be visible in all the views
        View::propagateVars([
            'myCustomVar' => 42,
            'clientHandler' => Config::get('Clients.HANDLER'),
        ]);
    }
}

About

A Blade templating language adaptation for the Viper Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages