From 0f53f7c2e98a96f269058a3b028912cc0b516ded Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 18:24:08 +0000 Subject: [PATCH 01/23] Add conditional directives Add tests for conditionals and loops --- syntax/blade.vim | 4 ++-- test.blade.php | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 3aeb130..b16ab3b 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -33,13 +33,13 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @includeIf @each @inject @extends @section @stack @push @unless @yield @parent @hasSection @break @continue \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required - \ @includeUnless @once @pushOnce + \ @includeUnless @once @pushOnce @context @session \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan \ @endcannot @stop @append @endsection @endpush @show @overwrite @verbatim @endverbatim @endcomponent \ @endslot @endprepend @endisset @endempty @endauth @endguest @endswitch @enderror @endproduction - \ @endenv @endonce @endPushOnce + \ @endenv @endonce @endPushOnce @endcontext @endsession @default \ containedin=ALLBUT,@bladeExempt if exists('g:blade_custom_directives') diff --git a/test.blade.php b/test.blade.php index 76810aa..cb5b51d 100644 --- a/test.blade.php +++ b/test.blade.php @@ -37,6 +37,8 @@ @forelse ($users as $user)
  • {{ $user->name }}
  • + @break ($user->last) + @continue ($user->skip) @empty

    No users

    @endforelse @@ -117,6 +119,10 @@

    This is appended to the master sidebar.

    @endsection +@sectionMissing('navigation') + default navigation +@endif + +@endcontext + @switch($i) @case(1) case code @break + + @default + default case + @endswitch @includeFirst From 3c837abc60562209f5df642514152a34d9e8d552 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 20:08:33 +0000 Subject: [PATCH 02/23] Add attribute directives Add attribute directives for use in html tags (or similar). --- syntax/blade.vim | 5 +++++ test.blade.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/syntax/blade.vim b/syntax/blade.vim index b16ab3b..722c2d8 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -42,6 +42,9 @@ syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse \ @endenv @endonce @endPushOnce @endcontext @endsession @default \ containedin=ALLBUT,@bladeExempt +syn keyword bladeAttrParen @class @style @checked @selected @disabled @readonly @required + \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeAttrExempt + if exists('g:blade_custom_directives') exe "syn keyword bladeKeyword @" . join(g:blade_custom_directives, ' @') . " nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt" endif @@ -57,6 +60,7 @@ syn region bladePhpParenBlock matchgroup=bladeDelimiter start="\s*(" end=")" c syn cluster bladePhp contains=@phpClTop syn cluster bladeExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,@htmlTop +syn cluster bladeAttrExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock syn cluster htmlPreproc add=bladeEcho,bladeComment,bladePhpRegion @@ -67,6 +71,7 @@ hi def link bladeDelimiter PreProc hi def link bladeComment Comment hi def link bladeTodo Todo hi def link bladeKeyword Statement +hi def link bladeAttrParen Special let b:current_syntax = 'blade' diff --git a/test.blade.php b/test.blade.php index cb5b51d..8124dd7 100644 --- a/test.blade.php +++ b/test.blade.php @@ -125,6 +125,26 @@ + + +isNotAdmin()) + @required($user->isAdmin()) +/> + + + [ @@ -222,4 +242,17 @@ @endswitch + $isActive, + 'big' => $size > 4, // html tag should not end yet + ]) + @style([ + 'margin: 0', + 'font-weight: bold' => $isActive, + ]) +>Link + @includeFirst From 305b4be85b9a28d6edd5b5301bfe54f468181aa7 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 20:12:12 +0000 Subject: [PATCH 03/23] tests for `@include*` directives --- test.blade.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test.blade.php b/test.blade.php index 8124dd7..cf58616 100644 --- a/test.blade.php +++ b/test.blade.php @@ -255,4 +255,7 @@ ]) >Link -@includeFirst +@includeIf('view.name') +@includeWhen($condition, 'view.name') +@includeUnless($condition, 'view.name') +@includeFirst(['custom.name', 'name']) From ae1b07787c585895516c3387dc86191386b125e8 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 20:57:41 +0000 Subject: [PATCH 04/23] add more push/prepend once directives note: `@endPrependOnce` is not documented for a preferred mix of upper/lower case, so assuming it should be written consistent with `@endPushOnce`. Directives are compiled by blade as case-insensitive. --- syntax/blade.vim | 4 ++-- test.blade.php | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 722c2d8..f5704e5 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -33,13 +33,13 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @includeIf @each @inject @extends @section @stack @push @unless @yield @parent @hasSection @break @continue \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required - \ @includeUnless @once @pushOnce @context @session + \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan \ @endcannot @stop @append @endsection @endpush @show @overwrite @verbatim @endverbatim @endcomponent \ @endslot @endprepend @endisset @endempty @endauth @endguest @endswitch @enderror @endproduction - \ @endenv @endonce @endPushOnce @endcontext @endsession @default + \ @endenv @endonce @endPushOnce @endPushIf @endPrependOnce @endcontext @endsession @default \ containedin=ALLBUT,@bladeExempt syn keyword bladeAttrParen @class @style @checked @selected @disabled @readonly @required diff --git a/test.blade.php b/test.blade.php index cf58616..704582d 100644 --- a/test.blade.php +++ b/test.blade.php @@ -82,9 +82,29 @@ @inject('metrics', 'App\Services\MetricsService') -@push('scripts') +@once + @push('scripts') + + @endpush +@endonce + +@pushOnce('scripts') -@endpush +@endPushOnce + +@pushIf($shouldPush, 'scripts') + +@elsePushIf($pushOther, 'scripts') + +@elsePush + +@endPushIf + +@hasstack('list') +
      + @stack('list') +
    +@endif @@ -104,6 +124,10 @@ @endprepend +@prependOnce('scripts') + +@endPrependOnce +
    @section('sidebar') This is the master sidebar. From 80290c39b6ee4de8e100719efb707f30e4458463 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 21:28:27 +0000 Subject: [PATCH 05/23] Add `@use` directive --- syntax/blade.vim | 2 +- test.blade.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index f5704e5..2ad99ff 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -33,7 +33,7 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @includeIf @each @inject @extends @section @stack @push @unless @yield @parent @hasSection @break @continue \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required - \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session + \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan diff --git a/test.blade.php b/test.blade.php index 704582d..2a86f33 100644 --- a/test.blade.php +++ b/test.blade.php @@ -1,5 +1,12 @@ @props(['foo' => 'bar', 'baz']) +@use('App\Models\Example', 'Alias') +@use('App\Models\{Foo, Bar}') +@use(function App\Helpers\format_currency) +@use(const App\Constants\MAX_ATTEMPTS) +@use(function App\Helpers\{format_currency, format_date}) +@use(const App\Constants\{MAX_ATTEMPTS, DEFAULT_TIMEOUT}) + Hello, {{ $name }}. From 7e8bc5054cec8bd99221d88c6a26b0454bc90900 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 22:12:47 +0000 Subject: [PATCH 06/23] Add data attributes --- syntax/blade.vim | 17 ++++++++++++++--- test.blade.php | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 2ad99ff..5c6267a 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -45,6 +45,10 @@ syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse syn keyword bladeAttrParen @class @style @checked @selected @disabled @readonly @required \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeAttrExempt +syn match bladeAttrVar "\<:\$\w\+=\@!" contains=phpIdentifier containedin=ALLBUT,@bladeAttrExempt +syn match bladeAttrString #\<:[A-Za-z0-9-\.]\+=\ze["']# nextgroup=bladePhpQuoteBlock containedin=ALLBUT,@bladeAttrExempt contains=bladeAttrEq +syn match bladeAttrEq '=' contained + if exists('g:blade_custom_directives') exe "syn keyword bladeKeyword @" . join(g:blade_custom_directives, ' @') . " nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt" endif @@ -57,10 +61,12 @@ syn region bladePhpRegion matchgroup=bladeKeyword start="\<@php\>\s*(\@!" end= syn match bladeKeyword "@php\ze\s*(" nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn region bladePhpParenBlock matchgroup=bladeDelimiter start="\s*(" end=")" contains=@bladePhp,bladePhpParenBlock skipwhite contained +syn region bladePhpQuoteBlock matchgroup=bladeDelimiter start='\(\<:[A-Za-z0-9-\.]\+=\)\@<="' end='"' contains=@bladePhp contained +syn region bladePhpQuoteBlock matchgroup=bladeDelimiter start="\(\<:[A-Za-z0-9-\.]\+=\)\@<='" end="'" contains=@bladePhp contained syn cluster bladePhp contains=@phpClTop -syn cluster bladeExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,@htmlTop -syn cluster bladeAttrExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock +syn cluster bladeExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,bladePhpQuoteBlock,@htmlTop +syn cluster bladeAttrExempt contains=bladeComment,bladePhpRegion,bladePhpParenBlock,bladePhpQuoteBlock syn cluster htmlPreproc add=bladeEcho,bladeComment,bladePhpRegion @@ -71,7 +77,12 @@ hi def link bladeDelimiter PreProc hi def link bladeComment Comment hi def link bladeTodo Todo hi def link bladeKeyword Statement -hi def link bladeAttrParen Special + +hi def link bladeAttr Special +hi def link bladeAttrParen bladeAttr +hi def link bladeAttrString bladeAttr +hi def link bladeAttrVar bladeAttr +hi def link bladeAttrEq htmlTag let b:current_syntax = 'blade' diff --git a/test.blade.php b/test.blade.php index 2a86f33..450e6d6 100644 --- a/test.blade.php +++ b/test.blade.php @@ -290,3 +290,9 @@ @includeWhen($condition, 'view.name') @includeUnless($condition, 'view.name') @includeFirst(['custom.name', 'name']) + + + + +{{-- double colon prefix not treated as php --}} + From 6d8da2ad235d0013a0afb3e060bbc2f4b1189025 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 23:15:14 +0000 Subject: [PATCH 07/23] Add `@aware` directive --- syntax/blade.vim | 1 + test.blade.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/syntax/blade.vim b/syntax/blade.vim index 5c6267a..435a0db 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,6 +34,7 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use + \ @aware \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan diff --git a/test.blade.php b/test.blade.php index 450e6d6..fe6dc5b 100644 --- a/test.blade.php +++ b/test.blade.php @@ -1,5 +1,7 @@ @props(['foo' => 'bar', 'baz']) +@aware(['parent' => 'property']) + @use('App\Models\Example', 'Alias') @use('App\Models\{Foo, Bar}') @use(function App\Helpers\format_currency) From 2e3a5adbe334d204bfa12cfecd0910daee5bb34b Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 23:30:11 +0000 Subject: [PATCH 08/23] fix `@@parent` directive This directive uses double `@@`. --- syntax/blade.vim | 2 +- test.blade.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 435a0db..7ffa5b2 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -30,7 +30,7 @@ syn region bladeEcho matchgroup=bladeDelimiter start="{!!" end="!!}" con syn region bladeComment matchgroup=bladeDelimiter start="{{--" end="--}}" contains=bladeTodo containedin=ALLBUT,@bladeExempt keepend syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot @elsecan @elsecannot @include - \ @includeIf @each @inject @extends @section @stack @push @unless @yield @parent @hasSection @break @continue + \ @includeIf @each @inject @extends @section @stack @push @unless @yield @@parent @hasSection @break @continue \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use diff --git a/test.blade.php b/test.blade.php index fe6dc5b..cee705c 100644 --- a/test.blade.php +++ b/test.blade.php @@ -2,6 +2,8 @@ @aware(['parent' => 'property']) +@extends('parent.name') + @use('App\Models\Example', 'Alias') @use('App\Models\{Foo, Bar}') @use(function App\Helpers\format_currency) @@ -148,7 +150,7 @@ @section('title', 'Page Title') @section('sidebar') - @parent + @@parent

    This is appended to the master sidebar.

    @endsection From 3cc1cc85b0c73a40f3ebd4b9e97161d98f0b24ef Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 23:38:42 +0000 Subject: [PATCH 09/23] Add form `@csrf`, `@method` directives Add tests to show `@error` ... `@enderror` --- syntax/blade.vim | 3 ++- test.blade.php | 55 ++++++++++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 7ffa5b2..b752470 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,13 +34,14 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use - \ @aware + \ @aware @method \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan \ @endcannot @stop @append @endsection @endpush @show @overwrite @verbatim @endverbatim @endcomponent \ @endslot @endprepend @endisset @endempty @endauth @endguest @endswitch @enderror @endproduction \ @endenv @endonce @endPushOnce @endPushIf @endPrependOnce @endcontext @endsession @default + \ @csrf \ containedin=ALLBUT,@bladeExempt syn keyword bladeAttrParen @class @style @checked @selected @disabled @readonly @required diff --git a/test.blade.php b/test.blade.php index cee705c..07984d4 100644 --- a/test.blade.php +++ b/test.blade.php @@ -158,27 +158,40 @@ default navigation @endif - - - - -isNotAdmin()) - @required($user->isAdmin()) -/> - - +
    + @method('PUT') + @csrf + + + + + @error('terms') +
    {{ $message }}
    + @enderror + + isNotAdmin()) + @required($user->isAdmin()) + /> + + +
    Date: Sun, 14 Dec 2025 23:49:09 +0000 Subject: [PATCH 10/23] Add `@fragment` directive --- syntax/blade.vim | 4 ++-- test.blade.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index b752470..c21a2ed 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,13 +34,13 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use - \ @aware @method + \ @aware @method @fragment \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan \ @endcannot @stop @append @endsection @endpush @show @overwrite @verbatim @endverbatim @endcomponent \ @endslot @endprepend @endisset @endempty @endauth @endguest @endswitch @enderror @endproduction - \ @endenv @endonce @endPushOnce @endPushIf @endPrependOnce @endcontext @endsession @default + \ @endenv @endonce @endPushOnce @endPushIf @endPrependOnce @endcontext @endsession @default @endfragment \ @csrf \ containedin=ALLBUT,@bladeExempt diff --git a/test.blade.php b/test.blade.php index 07984d4..29ba975 100644 --- a/test.blade.php +++ b/test.blade.php @@ -139,6 +139,10 @@ @endPrependOnce +@fragment('list') + +@endfragment +
    @section('sidebar') This is the master sidebar. From 339a56c792cdcb3a9285769cfc8f33e968945cf7 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sun, 14 Dec 2025 23:57:03 +0000 Subject: [PATCH 11/23] Add `@canany` directive --- syntax/blade.vim | 4 ++-- test.blade.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index c21a2ed..7135ac2 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,14 +34,14 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use - \ @aware @method @fragment + \ @aware @method @fragment @canany @elsecanany \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan \ @endcannot @stop @append @endsection @endpush @show @overwrite @verbatim @endverbatim @endcomponent \ @endslot @endprepend @endisset @endempty @endauth @endguest @endswitch @enderror @endproduction \ @endenv @endonce @endPushOnce @endPushIf @endPrependOnce @endcontext @endsession @default @endfragment - \ @csrf + \ @csrf @endcanany \ containedin=ALLBUT,@bladeExempt syn keyword bladeAttrParen @class @style @checked @selected @disabled @readonly @required diff --git a/test.blade.php b/test.blade.php index 29ba975..b0410df 100644 --- a/test.blade.php +++ b/test.blade.php @@ -72,6 +72,12 @@ @endcannot +@canany(['update', 'view'], $post) + +@elsecanany(['create'], \App\Models\Post::class) + +@endcanany +
    @include('shared.errors')
    From 1f2d7973d4373c096ef84e11cc055b03ec53b961 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Mon, 15 Dec 2025 00:07:10 +0000 Subject: [PATCH 12/23] add `@elseauth`, `@elseguest` directives --- syntax/blade.vim | 2 +- test.blade.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index 7135ac2..ffe5810 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,7 +34,7 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use - \ @aware @method @fragment @canany @elsecanany + \ @aware @method @fragment @canany @elsecanany @elseauth @elseguest \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan diff --git a/test.blade.php b/test.blade.php index b0410df..dfe1bfb 100644 --- a/test.blade.php +++ b/test.blade.php @@ -267,11 +267,15 @@ class="@error('terms') is-invalid @else is-valid @enderror" @endempty @auth('admin') - authenticated + authenticated as admin +@elseauth('editor') + authenticated as editor @endauth @guest('admin') - not authenticated + not authenticated as admin +@elseguest('editor') + not authenticated as admin or guest @endguest @production From c6b515867361c3bc59d5ef629f5efe300827a035 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Mon, 15 Dec 2025 00:13:55 +0000 Subject: [PATCH 13/23] Add `@bool` directive Outputs true / false as a string for use in attribute values or js --- syntax/blade.vim | 2 +- test.blade.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/blade.vim b/syntax/blade.vim index ffe5810..a5c732e 100644 --- a/syntax/blade.vim +++ b/syntax/blade.vim @@ -34,7 +34,7 @@ syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @cannot \ @unset @lang @choice @component @slot @prepend @json @isset @auth @guest @switch @case @includeFirst @empty \ @includeWhen @props @livewire @error @production @env @sectionMissing @disabled @readonly @required \ @includeUnless @once @pushOnce @pushIf @elsePushIf @elsePush @prependOnce @hasstack @context @session @use - \ @aware @method @fragment @canany @elsecanany @elseauth @elseguest + \ @aware @method @fragment @canany @elsecanany @elseauth @elseguest @bool \ nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @endforelse @endwhile @endcan diff --git a/test.blade.php b/test.blade.php index dfe1bfb..758857c 100644 --- a/test.blade.php +++ b/test.blade.php @@ -192,6 +192,7 @@ class="@error('terms') is-invalid @else is-valid @enderror" @disabled($disable) @readonly($user->isNotAdmin()) @required($user->isAdmin()) + aria-disabled="@bool($disable)" />