Skip to content

Commit

Permalink
Merge pull request #155 from jakebathman/master
Browse files Browse the repository at this point in the history
Fix complex directive matching
  • Loading branch information
Medalink committed Sep 14, 2017
2 parents 6f069da + 0db50db commit 5b6bf65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions blade.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ contexts:
0: punctuation.section.embedded.end.php
pop: true

- match: '(\s{0}|^)(\@)\b(acfrepeater|auth|block|break|can|cannot|choice|case|component|continue|debug|each|elsecan|elsecannot|elseif|embed|extends|for|foreach|forelse|guest|hasSection|hipchat|if|isset|include|includeIf|includeWhen|inject|lang|layout|macro|macrodef|minify|partial|php|push|render|section|servers|set|slack|slot|stack|story|switch|task|unless|unset|while|wpposts|yield)\b(?=(|\s*|)\(\()'
captures:
0: punctuation.section.embedded.php
2: constant.other.inline-data.html
3: entity.name.tag.block.any.html
push:
- meta_scope: custom.compiler.blade.php
- meta_content_scope: source.php.blade
- match: '(?<=\)\))'
pop: true
- include: 'scope:source.php'

- match: '(\s{0}|^)(\@)\b(acfrepeater|auth|block|break|can|cannot|choice|case|component|continue|debug|each|elsecan|elsecannot|elseif|embed|extends|for|foreach|forelse|guest|hasSection|hipchat|if|isset|include|includeIf|includeWhen|inject|lang|layout|macro|macrodef|minify|partial|php|push|render|section|servers|set|slack|slot|stack|story|switch|task|unless|unset|while|wpposts|yield)\b(?=(|\s*|)\()'
captures:
0: punctuation.section.embedded.php
Expand Down
14 changes: 14 additions & 0 deletions test.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,17 @@
@default
<p>Default</p>
@endswitch

{{-- Complex conditional --}}
@if(($x == true) && ($y == false))
<a>foo</a>
@endif

{{-- Single line if statement --}}
@if($foo === true) <p>Text</p> @endif

{{-- Quoted blade directive matching --}}
<p class="first-class @if($x==true) second-class @endif">Text</p>

{{-- Complex conditional inline --}}
<p class="first-class @if(($x == true) && ($y == "yes")) second-class @endif">Text</p>

0 comments on commit 5b6bf65

Please sign in to comment.