Skip to content

Commit

Permalink
Add component attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Oct 10, 2024
1 parent fe49618 commit 1e26d08
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
45 changes: 45 additions & 0 deletions Syntaxes/HTML (Blade).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,51 @@ contexts:
3: source.css.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

tag-attributes:
- meta_prepend: true
- include: tag-blade-attributes

tag-blade-attributes:
- match: :\w+\b
scope: entity.other.attribute-name.blade
push:
- tag-blade-attribute-meta
- tag-blade-attribute-assignment

tag-blade-attribute-meta:
- meta_include_prototype: false
- meta_scope: meta.attribute-with-value.blade
- include: immediately-pop

tag-blade-attribute-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.html
set: tag-blade-attribute-value
- include: else-pop

tag-blade-attribute-value:
- meta_include_prototype: false
# add extra meta.attribute-with-value.blade in escape_capture to work around
# https://github.com/sublimehq/sublime_text/issues/3784
- match: \"
scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
embed: scope:source.php#expressions
embed_scope: meta.string.html meta.embedded.html source.php.embedded.html
escape: \"
escape_captures:
0: meta.attribute-with-value.blade meta.string.html string.quoted.double.html punctuation.definition.string.end.html
pop: 1
- match: \'
scope: meta.string.html string.single.double.html punctuation.definition.string.begin.html
embed: scope:source.php#expressions
embed_scope: meta.string.html meta.embedded.html source.php.embedded.html
escape: \'
escape_captures:
0: meta.attribute-with-value.blade meta.string.html string.single.single.html punctuation.definition.string.end.html
pop: 1
- include: else-pop

tag-generic-attribute:
# fixes: https://github.com/Medalink/laravel-blade/issues/196
- meta_prepend: true
Expand Down
52 changes: 50 additions & 2 deletions tests/syntax_test_blade.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
{{-- ^ keyword.operator.assignment.php --}}
{{-- ^^^^ variable.other.php --}}
{{-- ^^ keyword.operator.null-coalescing.php --}}
{{-- ^^^^^ constant.language.boolean.php --}}
{{-- ^^^^^ constant.language.boolean --}}
{{-- ^ punctuation.section.arguments.end.blade - source.php --}}

@php($bool = $bool ?: true)
Expand All @@ -208,7 +208,7 @@
{{-- ^ keyword.operator.assignment.php --}}
{{-- ^^^^^ variable.other.php --}}
{{-- ^^ keyword.operator.ternary.php --}}
{{-- ^^^^ constant.language.boolean.php --}}
{{-- ^^^^ constant.language.boolean --}}
{{-- ^ punctuation.section.arguments.end.blade - source.php --}}
</div>

Expand Down Expand Up @@ -1200,3 +1200,51 @@
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html --}}
{{-- ^ punctuation.definition.tag.end.html --}}

<x-alert type="error" :message="$message" class="mt-4"/>
{{--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.other.html --}}
{{--^^^^^^^ entity.name.tag.other.html --}}
{{-- ^^^^^^^^^^^^ meta.attribute-with-value.html --}}
{{-- ^^^^ entity.other.attribute-name.html --}}
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^^^^^^^ meta.string.html string.quoted.double.html --}}
{{-- ^ punctuation.definition.string.begin.html --}}
{{-- ^ punctuation.definition.string.end.html --}}
{{-- ^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.blade --}}
{{-- ^^^^^^^^ entity.other.attribute-name.blade --}}
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^^^^^^^^^^ meta.string.html --}}
{{-- ^ string.quoted.double.html punctuation.definition.string.begin.html --}}
{{-- ^^^^^^^^ meta.embedded.html source.php.embedded.html variable.other.php --}}
{{-- ^ punctuation.definition.variable.php --}}
{{-- ^ string.quoted.double.html punctuation.definition.string.end.html --}}
{{-- ^^^^^^^^^^^^ meta.attribute-with-value.class.html --}}
{{-- ^^^^^ entity.other.attribute-name.class.html --}}
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}}
{{-- ^^^^ meta.class-name.html meta.string.html string.quoted.double.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}}
{{-- ^^ punctuation.definition.tag.end.html --}}

<x-nav-link :active="request()->is('$product')" href="/product">Product</x-nav-link>
{{--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.other.html --}}
{{-- ^^^^^^^^^^^^^ meta.tag.other.html --}}
{{--^^^^^^^^^^ entity.name.tag.other.html --}}
{{-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.blade --}}
{{-- ^^^^^^^ entity.other.attribute-name.blade --}}
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}}
{{-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html meta.embedded.html source.php.embedded.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}}
{{-- ^ - meta.attribute-with-value --}}
{{-- ^^^^^^^^^^^^^^^ meta.attribute-with-value.href.html --}}
{{-- ^^^^ entity.other.attribute-name.href.html --}}
{{-- ^ punctuation.separator.key-value.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}}
{{-- ^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html --}}
{{-- ^ punctuation.separator.path.html --}}
{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}}
{{-- ^ punctuation.definition.tag.end.html --}}
{{-- ^^ punctuation.definition.tag.begin.html --}}
{{-- ^^^^^^^^^^ entity.name.tag.other.html --}}
{{-- ^ punctuation.definition.tag.end.html --}}

0 comments on commit 1e26d08

Please sign in to comment.