2017 © Pedro Peláez
 

library blade

Blade templates outside of laravel.

image

sebastiansulinski/blade

Blade templates outside of laravel.

  • Wednesday, March 21, 2018
  • by sebastiansulinski
  • Repository
  • 1 Watchers
  • 1 Stars
  • 161 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Blade

Package to allow you use blade templates outside of Laravel., (*1)

Build Status, (*2)

Usage instructions

Blade constructor takes 4 arguments, 2 of which are optional:, (*3)

$viewPaths: // either a string or array of paths where your views will be fetched from
$cachePath: // string representing the path to the cache directory (to store cached version of the views)
Container $app = null: // instance of the Illuminate\Container\Container (optional)
Dispatcher $events = null: // instance of the Illuminate\Events\Dispatcher (optional)
Filesystem $events = null: // instance of the Illuminate\Events\Filesystem (optional)

With new instance of the Blade class you can call the view() methods the same way as from within Laravel using view() helper., (*4)

$blade = new Blade(
    realpath(__DIR__ . '/../resources/views'),
    realpath(__DIR__ . '/../resources/cache')
);

Passing variables

$user = User::find(1);

$blade->view('index', compact('user'));

$blade->view('index', ['user' => $user]);

$blade->view('index')->with('user', $user);

Determining if a view exists

$blade->view()->exists('test');

Sharing data with all views

$blade->share('user', $user);

View composers

$blade->view()->composer('dashboard', function(View $view) {

    $user = new stdClass;
    $user->name = 'Martin';

    $view->with('user', $user);

});

$blade->view('dashboard');
// has instance of $user available

Blade vew template

Use blade view templates the same way as with Laravel, (*5)

// index.blade.php

@extends('template.layout')

@section('content')



Hallo {{ $user->name }}

@endsection

Example

// /public/index.php

$blade = new Blade(
    realpath(__DIR__ . '/../resources/views'),
    realpath(__DIR__ . '/../resources/cache')
);

$user = User::find(1);

echo $blade->view('pages.index', compact('user'));


// /resources/views/template/layout.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Title</title>
</head>
<body>



@yield('content')
</body> </html> // /resources/views/pages/index.blade.php @extends('template.layout') @section('content')

Hallo {{ $user->name }}

@endsection

The Versions

21/03 2018

dev-master

9999999-dev

Blade templates outside of laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastian Sulinski

10/11 2017

v2.0.0

2.0.0.0

Blade templates outside of laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastian Sulinski

15/06 2017

v1.0.2

1.0.2.0

Blade templates outside of laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastian Sulinski

02/07 2016

v1.0.1

1.0.1.0

Blade templates outside of laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastian Sulinski

01/07 2016

v1.0.0

1.0.0.0

Blade templates outside of laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastian Sulinski