Laravel 블레이드

(라라벨 블레이드에서 넘어옴)
  다른 뜻에 대해서는 blade 문서를 참조하십시오.
  다른 뜻에 대해서는 블레이드 (1998) 문서를 참조하십시오.

1 개요[ | ]

Laravel Blade; Blade
라라벨 블레이드; 블레이드
  • 라라벨의 템플릿 엔진
  • 템플릿 파일 확장자: .blade.php
  • resource/views 디렉토리에 저장됨
  • 블레이드문은 블레이드 템플릿 엔진에 의해 모두 php 코드로 컴파일됨

2 데이터 표현[ | ]

  • 라우트에서 블레이드 뷰로 변수값을 넘겨 표현 할 수 있다.
라우트
Route::get('greeting', function () {
    return view('welcome', ['name' => 'John']);
});
블레이드 뷰
Hello, {{ $name }}.

3 제어문[ | ]

if문
@if (count($records) === 1)
    I have one record!
@elseif (count($records) > 1)
    I have multiple records!
@else
    I don't have any records!
@endif

4 반복문[ | ]

for문
@for ($i = 0; $i < 10; $i++)
    The current value is {{ $i }}
@endfor
foreach문
@foreach ($users as $user)
    <p>This is user {{ $user->id }}</p>
@endforeach
while문
@while (true)
    <p>I'm looping forever.</p>
@endwhile

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}