@yield
will search for a section established in the current page (or view) and will show it in that place, you can also add a default value in case there is nothing in that section.
Thus @yield('titulo', 'Mi sitio')
will include what is defined in @section Blog @endsection
in a view (the text Blog in this case), if nothing is defined, it will show the text My site.
The source code of @yield is:
protected function compileYield($expression)
{
return "<?php echo \$__env->yieldContent{$expression}; ?>";
}
public function yieldContent($section, $default = '')
{
$sectionContent = $default;
if (isset($this->sections[$section])) {
$sectionContent = $this->sections[$section];
}
$sectionContent = str_replace('@@parent', '--parent--holder--', $sectionContent);
return str_replace(
'--parent--holder--', '@parent', str_replace('@parent', '', $sectionContent)
);
}
@include
will simply include another view in the current one, so that @include('blog.articulo')
will find the file views\blog\articulo.blade.php
and will include it in the current view, all its contents.
The source code of @include is:
protected function compileInclude($expression)
{
if (Str::startsWith($expression, '(')) {
$expression = substr($expression, 1, -1);
}
return "<?php echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
}