Where to place Blade::extend

前端 未结 3 1288
眼角桃花
眼角桃花 2020-12-05 18:29

I want to add the following code to my laravel project to support the break and continue statements in blade.

This is the code:

Blade::extend(functio         


        
3条回答
  •  执笔经年
    2020-12-05 19:16

    There's no requirement telling you where you should put the code, you could even put it in your routes.php (which is a bit messy of course). You only have to make sure that it's loaded when laravel processes a page view.

    In this case, creating a new file blade_extensions.php somewhere and including it in start/global.php might be a good solution.

    PS: Be sure to clear out your compiled views, as Blade only recompiles the views if it detects a change, so if you've just plonked in this code it won't work until you clear out the views.

提交回复
热议问题