How to pass a custom function to a Laravel Blade template?

主宰稳场 提交于 2019-11-30 03:46:00
Joseph Silber

You don't have to pass anything to blade. If you define your function, you can use it from blade.


  1. Create a new app/helpers.php file.
  2. Add your trim_characters function to it.
  3. Add that file to your composer.json file.
  4. Run composer dump-autoload.

Now just use the function directly in blade:

{{ trim_characters($string) }}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!