Download the PHP package jobinja/blade-macro without Composer
On this page you can find all versions of the php package jobinja/blade-macro. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jobinja/blade-macro
More information about jobinja/blade-macro
Files in jobinja/blade-macro
Package blade-macro
Short Description Reusable scope-protected blade blocks, with empty I/O on runtime (replacement for @include which uses native I/O based PHP includes).
License MIT
Informations about the package blade-macro
Blade Macro
This package introduces a new blade directive called @macro
which allows reusable scope-protected blade code blocks.
Just like what @include
does but with zero runtime I/O.
@include
uses native PHP include
directive, which causes runtime I/O, Event if Opcache is fully enabled.
But sometimes @include
is used when we want to just Don't repeat ourselves
But this abstraction should not cause any performance bottleneck.
Installation
For Laravel >= 5.5.0:
For Laravel <= 5.3.0:
Usage
Just use the following service provider in your app.php
:
Then you can simply replace your needed old @include
directives with the new @macro
one:
Configuration
By default the package re-compiles blade views on each request in development environment, if you want to disable this feature run:
and config the package based on your needs.
Problem
Please see #16583 or simply read the following:
Consider the following loop:
The above code will be replaced by something like the following:
The above code includes the iteration_presenter.blade.php file for 5,000,000 times, which causes heavy I/O calls, but the only
reason we have used the iteration_presenter
partial is to create more abstraction and don't repeat ourselves.
Solution
Instead of using native include
directive we have created a new @macro
directive which simply copy/pastes the
partial content in compile time, and simply there is no I/O then:
The above @macro
directive will be translated to the following:
Running tests
License
Licensed under MIT, part of the effort for making Jobinja.ir better.
All versions of blade-macro with dependencies
illuminate/view Version 5.6.* || 5.5.*
illuminate/contracts Version 5.6.* || 5.5.*
illuminate/support Version 5.6.* || 5.5.*