From 6cdaa62f965a6118a4b091cc16e75cd45b781084 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20H=C3=A4drich?=
<11225821+shaedrich@users.noreply.github.com>
Date: Sun, 20 Oct 2024 02:26:11 +0200
Subject: [PATCH 1/2] Use Torchlight code fence filename attribute
---
blade.md | 51 +++++++++++++--------------------------------------
validation.md | 8 ++------
views.md | 4 +---
3 files changed, 16 insertions(+), 47 deletions(-)
diff --git a/blade.md b/blade.md
index e124c9cfb2a..74bdff3349f 100644
--- a/blade.md
+++ b/blade.md
@@ -1133,9 +1133,7 @@ By default, some keywords are reserved for Blade's internal use in order to rend
You will often need to pass additional content to your component via "slots". Component slots are rendered by echoing the `$slot` variable. To explore this concept, let's imagine that an `alert` component has the following markup:
-```blade
-
-
+```blade filename=/resources/views/components/alert.blade.php
{{ $slot }}
@@ -1151,9 +1149,7 @@ We may pass content to the `slot` by injecting content into the component:
Sometimes a component may need to render multiple different slots in different locations within the component. Let's modify our alert component to allow for the injection of a "title" slot:
-```blade
-
-
+```blade filename=/resources/views/components/alert.blade.php
{{ $title }}
@@ -1388,9 +1384,7 @@ Since anonymous components do not have any associated class, you may wonder how
You may specify which attributes should be considered data variables using the `@props` directive at the top of your component's Blade template. All other attributes on the component will be available via the component's attribute bag. If you wish to give a data variable a default value, you may specify the variable's name as the array key and the default value as the array value:
-```blade
-
-
+```blade filename=/resources/views/components/alert.blade.php
@props(['type' => 'info', 'message'])
merge(['class' => 'alert alert-'.$type]) }}>
@@ -1418,9 +1412,7 @@ Sometimes you may want to access data from a parent component inside a child com
The `` component may have an implementation like the following:
-```blade
-
-
+```blade filename=/resources/views/components/menu/index.blade.php
@props(['color' => 'gray'])
merge(['class' => 'bg-'.$color.'-200']) }}>
@@ -1430,9 +1422,7 @@ The `` component may have an implementation like the following:
Because the `color` prop was only passed into the parent (``), it won't be available inside ``. However, if we use the `@aware` directive, we can make it available inside `` as well:
-```blade
-
-
+```blade filename=/resources/views/components/menu/item.blade.php
@aware(['color' => 'gray'])
merge(['class' => 'text-'.$color.'-800']) }}>
@@ -1487,9 +1477,7 @@ Most web applications maintain the same general layout across various pages. It
For example, imagine we are building a "todo" list application. We might define a `layout` component that looks like the following:
-```blade
-
-
+```blade filename=/resources/views/components/layout.blade.php
{{ $title ?? 'Todo Manager' }}
@@ -1507,9 +1495,7 @@ For example, imagine we are building a "todo" list application. We might define
Once the `layout` component has been defined, we may create a Blade view that utilizes the component. In this example, we will define a simple view that displays our task list:
-```blade
-
-
+```blade filename=/resources/views/tasks.blade.php
@foreach ($tasks as $task)
{{ $task }}
@@ -1519,9 +1505,7 @@ Once the `layout` component has been defined, we may create a Blade view that ut
Remember, content that is injected into a component will be supplied to the default `$slot` variable within our `layout` component. As you may have noticed, our `layout` also respects a `$title` slot if one is provided; otherwise, a default title is shown. We may inject a custom title from our task list view using the standard slot syntax discussed in the [component documentation](#components):
-```blade
-
-
+```blade filename=/resources/views/tasks.blade.php
Custom Title
@@ -1551,9 +1535,7 @@ Layouts may also be created via "template inheritance". This was the primary way
To get started, let's take a look at a simple example. First, we will examine a page layout. Since most web applications maintain the same general layout across various pages, it's convenient to define this layout as a single Blade view:
-```blade
-
-
+```blade filename=resources/views/layouts/app.blade.php
App Name - @yield('title')
@@ -1579,9 +1561,7 @@ Now that we have defined a layout for our application, let's define a child page
When defining a child view, use the `@extends` Blade directive to specify which layout the child view should "inherit". Views which extend a Blade layout may inject content into the layout's sections using `@section` directives. Remember, as seen in the example above, the contents of these sections will be displayed in the layout using `@yield`:
-```blade
-
-
+```blade filename=/resources/views/child.blade.php
@extends('layouts.app')
@section('title', 'Page Title')
@@ -1642,9 +1622,7 @@ Since HTML forms can't make `PUT`, `PATCH`, or `DELETE` requests, you will need
The `@error` directive may be used to quickly check if [validation error messages](/docs/{{version}}/validation#quick-displaying-the-validation-errors) exist for a given attribute. Within an `@error` directive, you may echo the `$message` variable to display the error message:
-```blade
-
-
+```blade filename=/resources/views/post/create.blade.php
-
+```blade filename=/resources/views/auth.blade.php
+```blade filename=/resources/views/auth.blade.php
diff --git a/validation.md b/validation.md
index 43d71477dab..e913198097f 100644
--- a/validation.md
+++ b/validation.md
@@ -175,9 +175,7 @@ An `$errors` variable is shared with all of your application's views by the `Ill
So, in our example, the user will be redirected to our controller's `create` method when validation fails, allowing us to display the error messages in the view:
-```blade
-
-
+```blade filename=/resources/views/post/create.blade.php
Create Post
@if ($errors->any())
@@ -215,9 +213,7 @@ In this example, we used a traditional form to send data to the application. How
You may use the `@error` [Blade](/docs/{{version}}/blade) directive to quickly determine if validation error messages exist for a given attribute. Within an `@error` directive, you may echo the `$message` variable to display the error message:
-```blade
-
-
+```blade filename=/resources/views/post/create.blade.php
-
+```blade filenname=/resources/views/greeting.blade.php
Hello, {{ $name }}
From ac0ae561c8187b042a4c4c25d7d9488ea52eab95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20H=C3=A4drich?=
<11225821+shaedrich@users.noreply.github.com>
Date: Sun, 20 Oct 2024 02:29:57 +0200
Subject: [PATCH 2/2] Add leading slash for consistency
---
blade.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blade.md b/blade.md
index 74bdff3349f..6e657c3f755 100644
--- a/blade.md
+++ b/blade.md
@@ -1535,7 +1535,7 @@ Layouts may also be created via "template inheritance". This was the primary way
To get started, let's take a look at a simple example. First, we will examine a page layout. Since most web applications maintain the same general layout across various pages, it's convenient to define this layout as a single Blade view:
-```blade filename=resources/views/layouts/app.blade.php
+```blade filename=/resources/views/layouts/app.blade.php
App Name - @yield('title')