<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>@yield in Blade Templates Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/yield-in-blade-templates/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/yield-in-blade-templates/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Mon, 04 Dec 2023 12:18:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>What is Blade Template in Laravel and How to Create Layouts in Blade Template?</title>
		<link>https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/</link>
					<comments>https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/#respond</comments>
		
		<dc:creator><![CDATA[Maruti Kr.]]></dc:creator>
		<pubDate>Mon, 04 Dec 2023 12:18:25 +0000</pubDate>
				<category><![CDATA[laravel]]></category>
		<category><![CDATA[@yield in Blade Templates]]></category>
		<category><![CDATA[Blade Template Extending]]></category>
		<category><![CDATA[Blade Template Structure]]></category>
		<category><![CDATA[Blade Templating Engine]]></category>
		<category><![CDATA[Creating Views in Laravel]]></category>
		<category><![CDATA[Laravel @extends Directive]]></category>
		<category><![CDATA[Laravel Blade @section Directive]]></category>
		<category><![CDATA[Laravel Blade Template]]></category>
		<category><![CDATA[Laravel View Layouts]]></category>
		<category><![CDATA[Layout Creation in Laravel]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=18197</guid>

					<description><![CDATA[<p>Introduction Blade Template in Laravel is a powerful templating engine that allows you to write clean and efficient PHP code for creating views in your Laravel application. It provides a way to separate your logic (such as conditional statements and loops) from your presentation, resulting in more maintainable and reusable code. To create layouts in <a class="read-more-link" href="https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/">What is Blade Template in Laravel and How to Create Layouts in Blade Template?</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/12/image-46.png" alt="" class="wp-image-18198" width="838" height="469"/></figure>



<h2 class="wp-block-heading">Introduction</h2>



<p>Blade Template in Laravel is a powerful templating engine that allows you to write clean and efficient PHP code for creating views in your Laravel application. It provides a way to separate your logic (such as conditional statements and loops) from your presentation, resulting in more maintainable and reusable code.  </p>



<p>To create layouts in Blade Template, you can follow these steps:</p>



<ol class="wp-block-list">
<li><strong>Create a layout file:</strong> Start by creating a layout file that will serve as the base for your views. This file typically contains the common structure of your web pages, such as headers, footers, navigation bars, etc. Let&#8217;s name it <code>layout.blade.php</code>.</li>
</ol>



<pre class="wp-block-code"><code>&lt;!-- layout.blade.php -->
&lt;html>
    &lt;head>
        &lt;title>@yield('title')&lt;/title>
    &lt;/head>
    &lt;body>
        &lt;header>
            &lt;!-- Header content -->
        &lt;/header>

        &lt;main>
            @yield('content')
        &lt;/main>

        &lt;footer>
            &lt;!-- Footer content -->
        &lt;/footer>
    &lt;/body>
&lt;/html></code></pre>



<p><strong>2.</strong> <strong>Extending the Layout: </strong>Create individual views that extend this layout. Use the <code>@extends</code> directive to specify the layout to inherit from and define the sections to be replaced.</p>



<pre class="wp-block-code"><code>&lt;!-- home.blade.php -->
@extends('layout')

@section('title', 'Home Page')

@section('content')
    &lt;!-- Content for the home page -->
@endsection
</code></pre>



<p><strong>3.</strong> <strong>Including Views:</strong> You can include partials or reusable components within your views using the <code>@include</code> directive.</p>



<pre class="wp-block-code"><code>&lt;!-- home.blade.php -->
@extends('layout')

@section('title', 'Home Page')

@section('content')
    &lt;!-- Content for the home page -->
    @include('partials.posts') &lt;!-- Including a partial -->
@endsection
</code></pre>



<p><strong>4.</strong> <strong>Using Variables:</strong> You can pass data to views using an associative array or an object and then access these variables within the Blade templates.</p>



<pre class="wp-block-code"><code>&lt;!-- home.blade.php -->
@extends('layout')

@section('title', $pageTitle)

@section('content')
    &lt;h1>{{ $welcomeMessage }}&lt;/h1>
@endsection
</code></pre>



<p><strong>5. Conditional Rendering and Loops:</strong> Blade provides directives like <code>@if</code>, <code>@else</code>, <code>@foreach</code>, and <code>@while</code> for handling conditional logic and looping through data.</p>



<pre class="wp-block-code"><code>@if ($condition)
    &lt;!-- Display something -->
@else
    &lt;!-- Display something else -->
@endif

@foreach ($items as $item)
    &lt;p>{{ $item }}&lt;/p>
@endforeach
</code></pre>



<p>By following these steps, you can create a consistent layout structure for your web application and easily manage content in individual views using Laravel&#8217;s Blade templating engine.</p>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/">What is Blade Template in Laravel and How to Create Layouts in Blade Template?</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/what-is-blade-template-in-laravel-and-how-to-create-layouts-in-blade-template/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
