bilaliqbalr / laravel-string-blade-compiler by bilaliqbalr
forked from digivo/laravel-string-blade-compiler

Render Blade templates from a string
1,018
2
3
Package Data
Maintainer Username: bilaliqbalr
Maintainer Contact: bilal@phalcosoft.com (Bilal)
Package Create Date: 2017-08-15
Package Last Update: 2018-07-03
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:05:36
Package Statistics
Total Downloads: 1,018
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 3
Total Forks: 2
Total Open Issues: 2

String Blade Compiler

Originally forked from Flynsarmy/laravel-db-blade-compiler

Render Blade templates from a string

This package generates and returns a compiled view from a provided string

Installation (Laravel 5.4.x)

Require this package in your composer.json and run composer update (or run composer require bilaliqbalr/laravel-string-blade-compiler:1.* directly):

"bilaliqbalr/laravel-string-blade-compiler": "1.*"

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

Bilaliqbalr\StringBladeCompiler\StringBladeCompilerServiceProvider::class,

and the Facade to the aliases array in the same file

'StringView'          => Bilaliqbalr\StringBladeCompiler\Facades\StringView::class,

You have to also publish the config-file

php artisan vendor:publish

Usage

This package offers a StringView facade with the same syntax as View but accepts a string instead of path to view.

return StringView::make('@if ($foo == "Bar") foo is Bar @else foo is not Bar @endif')->with(['foo' => 'Bar'])->render();

License

laravel-string-blade-compiler is open-sourced software licensed under the MIT license