I would like to create helper functions to avoid repeating code between views in Laravel 5:
view.blade.php
Foo Formated text: {{ fo
Yes, there is another way to do this!
Step 1: Register a custom Blade directive:
Custom Link';
});
}
...
Step 2: Use your custom Blade directive:
@shout('this is my custom blade directive!!')
@customLink
Outputs:
THIS IS MY CUSTOM BLADE DIRECTIVE!!
Custom Link
Source: https://laravel.com/docs/5.1/blade#extending-blade
Additional Reading: https://mattstauffer.co/blog/custom-conditionals-with-laravels-blade-directives
If you want to learn how to best make custom classes that you can use anywhere, see Custom Classes in Laravel 5, the Easy Way