Skip to content

Instantly share code, notes, and snippets.

@JacobBennett
Last active August 29, 2015 14:13
Show Gist options
  • Save JacobBennett/2b9b3f7e9c7f7c8af463 to your computer and use it in GitHub Desktop.
Save JacobBennett/2b9b3f7e9c7f7c8af463 to your computer and use it in GitHub Desktop.
Set of blade yield, section, and extend use cases that are handy to remember without having to look up http://daylerees.com/codebright/blade every time :)

Default yield statement

@yield('section_name')

Default Section

@section('section_name')
	content that will always be present
@stop

Single line yield statement

use this for injecting class names, or single line, space sensitive values

@yield('section_name', 'default_value')

Single line section statement

use this with the single line yield statement above

@section('section_name', 'value')

Section with default content

similar to a yield but with default content and allows child overriding

@section('section_name')
	default content goes in here
	multi lines and all sorts of codez
	<style>blabla</style>
@show

Append to a parent section instead of replacing it

using the @parent keyword

View 1

@section('message')
	Hello
	@yield('message')
@stop

View 2

@extends('View 1')

@section('message')
	@parent
	There
@stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment