2017 © Pedro Peláez
 

project laravel-fly-view

Render Blade templates from string mark-up

image

johnturingan/laravel-fly-view

Render Blade templates from string mark-up

  • Friday, February 23, 2018
  • by redgreenyellow
  • Repository
  • 3 Watchers
  • 6 Stars
  • 282 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 41 % Grown

The README.md

Laravel-fly-view

Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string template and recompiles it if needed., (*1)

This is useful if you want to render your template which came from other sources like CMS or third party API, (*2)

Since its an Extension of laravel View class. It will not interfere on the usual flow of your application. You can still use laravel view as per normal but with the capability of passing string template., (*3)

It supports all directives of Blade Template., (*4)

Supports Laravel 5.2+, (*5)

Installation :traffic_light:

Add the package to your composer.json, (*6)

"require": {
    ...
    "johnturingan/laravel-fly-view": "{version}"
},

Or just run composer require, (*7)

$ composer require johnturingan/laravel-fly-view

In config/app.php replace, (*8)

Illuminate\View\ViewServiceProvider::class

with, (*9)

Snp\FlyView\Providers\ViewServiceProvider::class

Usage :white_check_mark:

View normal usage:

Pass path to blade file using dot notation on the first parameter, (*10)

return view('path.to.view', []);
Flyview usage:

Pass array of strings on the first parameter, (*11)

return view([ 'String Template with {{$blade}} syntax and @directives' ], []);

or you can do, (*12)

return view([
    '{{ $token }}',
    '{{ $me }}'
], [
    'token' => Str::uuid(),
    'me' => 'Laravel Fly View'
]);

Flyview will merge all strings inside the array before compile. Useful if you have multiple template sources., (*13)

You can also use if from response helper like this., (*14)

return response()->view([
    '{{ $token }}',
    '{{ $me }}'
], [
    'token' => Str::uuid(),
    'me' => 'Laravel Fly View on Response Helper'
]);

Like I said before, it will not interfere the usual flow of Laravel View. Meaning you can do something like this., (*15)

$bag = [
    'include' => [
        '{{ $token }} - This is FlyView Include',
        '@include("includes.nativeInclude") <br/> Above is Include Inception'
    ],
    'data' => [ 'token' => Str::uuid() ]
];

return view('includeTest', $bag);

Inside your includeTest.blade.php file is this:, (*16)

@include('includes.nativeInclude', $data)

@include($include, $data)

Including string template to blade template file is possible., (*17)

Config :page_facing_up:

All configuration is same as the default view config in your config folder with an additional settings to minimize view contents. Default is false., (*18)

/*
    |--------------------------------------------------------------------------
    | Minify View Content
    |--------------------------------------------------------------------------
    |
    | This option determines whether or not you want to minify view contents.
    | It removes unnecessary whitespace
    |
    */
    'minify' => false

NOTE:, (*19)

If you find any bugs or you have some ideas in mind that would make this better. Please don't hesitate to send comment on github., (*20)

If you find this package helpful, a simple star is very much appreciated., (*21)


MIT LICENSE
copyright © 2018 Scripts and Pixels., (*22)

The Versions

23/02 2018

dev-master

9999999-dev

Render Blade templates from string mark-up

  Sources   Download

MIT

The Requires

 

laravel template blade view view caching render string mark-up view on the fly

23/02 2018

v1.1.1

1.1.1.0

Render Blade templates from string mark-up

  Sources   Download

MIT

The Requires

 

laravel template blade view view caching render string mark-up view on the fly

23/02 2018

v1.1.0

1.1.0.0

Render Blade templates from string mark-up

  Sources   Download

MIT

The Requires

 

laravel template blade view view caching render string mark-up view on the fly

15/02 2018

v1.0.0

1.0.0.0

Render Blade templates from string mark-up

  Sources   Download

MIT

The Requires

 

laravel template blade view view caching render string mark-up view on the fly