Skip to content

Instantly share code, notes, and snippets.

@gbrock
Last active April 13, 2022 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbrock/6b5b97adb2210160171f to your computer and use it in GitHub Desktop.
Save gbrock/6b5b97adb2210160171f to your computer and use it in GitHub Desktop.
Starter Blade templates
@extends('html5')
@section('title'){{ isset($title) ? $title . ' – ' : '' }}{{ trans('app.name') }}{{--
--}}@overwrite
@section('main')
<div id="wrapper">
<div id="main">
@yield('main.prepend')
<div id="content">
@yield('content.prepend')
@yield('content')
@yield('content.append')
</div>
@yield('main.append')
</div>
</div>
@yield('footer')
@endsection
@section('styles')
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
@endsection
@section('scripts')
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@endsection

Starter Blade Templates

A simple starting point for use in Laravel 5.1. Based on Flexible master layout by Sercan Çakır.

Usage

  1. Download html5.blade.php and app.blade.php into your application's resources/views folder.
  2. In your app's custom views, extend app and hook into the yield points to flesh out your pages:
    {{--  myfile.blade.php  --}}
    @extends('app', [
      'title' => 'My Page Title',
    ])
    
    {{--  the "content" section is the main body of the page. --}}
    @section('content')
      <h1>Hello, world!</h1>
    @stop
  3. Continue fleshing out app.blade.php with your site-wide templating as-needed.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>@yield('title', 'default title')</title>
<meta name="csrf-token" content="<?= csrf_token() ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width">
@yield('meta')
@yield('styles')
</head>
<body class="{{$body_class or ''}}">
@yield('main')
@yield('scripts')
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment