As the docs says:
Blade also provides convenient shortcuts for common PHP control structures, such as conditional statements and loops. These shortcuts provide a very clean, terse way of working with PHP control structures, while also remaining familiar to their PHP counterparts.
As you can see, the main purpose is to create shorcuts that are "cleaner" when reading. A better API.
Update
As @ceejayoz mentioned, its also extendible. Blade let's you create your own directives to be used in your views. This directives can also receive parameters.
Extending Blade
Blade allows you to define your own custom directives using the
directive
method. When the Blade compiler encounters the custom
directive, it will call the provided callback
with the expression
that the directive contains.
The following example creates a @datetime($var)
directive which
formats a given $var
, which should be an instance of DateTime
:
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
Blade::directive('datetime', function ($expression) {
return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";
});
}
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
//
}
}
As you can see, we will chain the format method onto whatever
expression is passed into the directive. So, in this example, the
final PHP generated by this directive will be:
<?php echo ($var)->format('m/d/Y H:i'); ?>