Level 5
You can start following the documentation example:
https://laravel.com/docs/5.6/blade#extending-blade
Blade::directive('datetime', function ($expression) {
return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";
});
1 like
Summer Sale! All accounts are 50% off this week.
I've created a Blade directive
Blade::directive('img', function ($object) {
//
});
How can I pass an object to the function closure? it accepts only strings.
@img($object)
blade is building a string that will be inserted into your view. It does not run when the blade file is processed.
The string that is passed through needs to be returned from your blade to construct the runtime expression
Please or to participate in this conversation.