# Laravel Blade Templates: Writing HTML the Smart Way ## Introduction Blade is Laravel's template engine. Think of it like a smart notebook that lets you write HTML mixed with small PHP snippets, but cleaner. ## What is Blade? Blade files use the `.blade.php` extension. They live in `resources/views/`. Laravel compiles them to plain PHP behind the scenes. ## Your First Blade View Create `resources/views/hello.blade.php`:

Hello, {{ $name }}!

The `{{ }}` syntax safely prints a variable (auto-escaped). ## Passing Data from a Route Route::get('/hello/{name}', function ($name) { return view('hello', ['name' => $name]); }); ## If / Else in Blade @if($age >= 18)

You are an adult.

@else

You are a minor.

@endif ## Loops in Blade
    @foreach($fruits as $fruit)
  • {{ $fruit }}
  • @endforeach
## 3 Things to Remember - Blade files use `.blade.php` and live in `resources/views/`. - `{{ }}` prints variables safely (auto-escaped). - Use `@if`, `@foreach`, `@else` for logic in templates.