在Laravel框架中,.blade文件有什么用途?

3
我在views文件夹中遇到了welcome.blade.php文件。
这个文件名中的.blade有什么作用?
2个回答

4

Laravel使用Blade模板引擎作为其模板引擎(例如,smarty曾经非常流行),其扩展名为.blade.php。可以在此处找到更多细节。


如果我在文件名中不加.blade会发生什么? - Van Adrian Cabrera
1
试一下,看看会发生什么。 - Andy Holmes
长话短说,你的视图将停止工作。正如@AndyHolmes提到的那样,试一下,阅读并理解我分享的链接。 - Abbasi

0

正如Abbasi所提到的,Blade是一个模板引擎。我想分享一个关于Blade和Laravel的好资源,其中提供了一些不错的示例,例如:

@extends('layout.name')
// Begin a section
 @section('name')
// End a section
 @stop
// End a section and yield
 @show
@parent
// Show a section in a template
 @yield('name')
@include('view.name')
@include('view.name', array('key' => 'value'));
@lang('messages.name')
@choice('messages.name', 1);
@if
@else
@elseif
@endif
@unless
@endunless
@for
@endfor
@foreach
@endforeach
@while
@endwhile
//forelse 4.2 feature
 @forelse($users as $user)
@empty
@endforelse
// Echo content
 {{ $var }}
// Echo escaped content
 {{{ $var }}}
{{-- Blade Comment --}}
// Echoing Data After Checking For Existence
 {{{ $name or 'Default' }}}
// Displaying Raw Text With Curly Braces
 @{{ This will not be processed by Blade }}

请查看此网站,了解其他Laravel语法助手。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接