laravel-blade
How do I use nl2br() in Laravel 5 Blade
You can define your own “echo format” that will be used with the regular content tags {{ … }}. The default format is e(%s) (sprintf is used to apply the formatting) To change that format call setEchoFormat() inside a service provider: public function boot(){ \Blade::setEchoFormat(‘nl2br(e(%s))’); } Now you can just use the normal echo tags: … Read more
How can I know the size of an array in Blade template?
It is possible with the count function, like so: @if (count($array) > 0) {{– expr –}} @endif
Laravel – Difference between @yield and @section?
Short Answer: Always use @yield unless you want to do something more complicated then providing a default string. Long Answer: Both @yield and @section .. @show are used to be optionally overwritten whenever you extend the blade template. Everything you can do with @yield can also be done with @section .. @show but not the … Read more
Blade inline if and else if statement
You can use this code in laravel blade: {{ $var === “hello” ? “Hi” : ($var ===”howdie ? “how” : “Goodbye”) }}
What is the difference between Section and Stack in Blade?
I might be mistaken, but the difference is not only semantically, but in behaviour as well. With @push you append as many times as needed to a stack, while (by default) you may fill @section only once in your views. In some situations this comes in handy when you need to add content from different … Read more