Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Question 9 of 10 · Laravel Framework Fundamentals
Interview question

How does Laravel's Blade templating engine work? Laravel का Blade templating engine कैसे काम करता है?

Answer

Blade is Laravel's templating engine that compiles templates into plain PHP code, which is then cached for performance until the source file changes.

{{-- resources/views/welcome.blade.php --}}
@extends('layouts.app')

@section('content')
    <h1>Hello, {{ $name }}</h1>
    @if ($user->isAdmin())
        <p>Welcome, admin!</p>
    @endif
    @foreach ($posts as $post)
        <p>{{ $post->title }}</p>
    @endforeach
@endsection
DirectivePurpose
{{ }}Echo, auto-escaped for XSS safety
{!! !!}Echo raw, unescaped HTML
@extends / @sectionTemplate inheritance

Blade Laravel का templating engine है जो templates को plain PHP code में compile करता है और performance के लिए cache करता है।

@extends('layouts.app')

@section('content')
    <h1>Hello, {{ $name }}</h1>
    @foreach ($posts as $post)
        <p>{{ $post->title }}</p>
    @endforeach
@endsection

Was this answer clear?