library laravel-raw-view
It's intended to compile a view from the HTML string 'on the fly'. You don't need to create a view file.
sergant210/laravel-raw-view
It's intended to compile a view from the HTML string 'on the fly'. You don't need to create a view file.
- Thursday, March 29, 2018
- by sergant210
- Repository
- 1 Watchers
- 0 Stars
- 2 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
RawView
RawView for Laravel 5.5+ gives an ability to compile a view from the raw HTML code with Blade directives without creating a view file., (*1)
Install
Via Composer, (*2)
``` bash
$ composer require sergant210/laravel-raw-view, (*3)
After that the view_raw function will be available. It works like the view function but you must specify the HTML code instead of the name of the view.
## Usage
``` php
class Item
{
public $tpl = '<li class="{{ $item->makeClasses() }}"> {{ $item->name }}';
...
public function render()
{
return view_raw($this->tpl, ['item' => $this])->render();
}
}
// View
@foreach($items as $item)
{!! $item->render() !!}
@endforeach
Changelog
Please see CHANGELOG for more information on what has changed recently., (*4)
License
The MIT License (MIT). Please see License File for more information., (*5)