Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component attributes #206

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 67 additions & 8 deletions Syntaxes/HTML (Blade).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ file_extensions:

contexts:

###[ HTML TAGS ]###############################################################

prototype:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-embedded
Expand All @@ -29,6 +31,12 @@ contexts:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-interpolations

strings-common-content:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-interpolations

###[ HTML SCRIPT TAG ]#########################################################

script-javascript-content:
- meta_include_prototype: false
- match: \s*((<!\[)(CDATA)(\[))
Expand Down Expand Up @@ -56,6 +64,8 @@ contexts:
3: source.js.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

###[ HTML STYLE TAG ]##########################################################

style-css-content:
- meta_include_prototype: false
- match: \s*((<!\[)(CDATA)(\[))
Expand Down Expand Up @@ -83,6 +93,12 @@ contexts:
3: source.css.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

###[ HTML TAG ATTRIBUTES ]#####################################################

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

tag-generic-attribute:
# fixes: https://github.com/Medalink/laravel-blade/issues/196
- meta_prepend: true
Expand All @@ -92,6 +108,55 @@ contexts:
- tag-generic-attribute-meta
- tag-generic-attribute-value

tag-attribute-value-content:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-interpolations

###[ COMPONENT ATTRIBUTE ]#####################################################

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

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

tag-blade-attribute-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.html
set:
- immediately-pop # workaround https://github.com/sublimehq/sublime_text/issues/4069
- tag-blade-attribute-value
- include: else-pop

tag-blade-attribute-value:
- meta_include_prototype: false
- 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.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.string.html string.single.single.html punctuation.definition.string.end.html
pop: 1
- include: else-pop

###[ EVENT ATTRIBUTE ]#########################################################

tag-event-attribute-value:
# note: only needed for backward compatibility with ST4143
- meta_include_prototype: false
Expand Down Expand Up @@ -129,6 +194,8 @@ contexts:
tag-event-attribute-value-single-quoted-content:
- include: scope:source.js.blade.embedded.string.quoted.single

###[ STYLE ATTRIBUTE ]#########################################################

tag-style-attribute-value:
# note: only needed for backward compatibility with ST4143
- meta_include_prototype: false
Expand Down Expand Up @@ -165,11 +232,3 @@ contexts:

tag-style-attribute-value-single-quoted-content:
- include: scope:source.css.blade.embedded.string.quoted.single

tag-attribute-value-content:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-interpolations

strings-common-content:
- meta_prepend: true
- include: Blade.sublime-syntax#blade-interpolations
2 changes: 1 addition & 1 deletion tests/syntax_test_blade.blade.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* ^ - meta.embedded.blade source.blade meta.directive */
/* ^^^ keyword.control.directive.blade */
/* ^ punctuation.section.arguments.begin.blade */
/* ^^^^ source.php.embedded.blade constant.language.boolean.php */
/* ^^^^ source.php.embedded.blade constant.language.boolean */
/* ^ punctuation.section.arguments.end.blade */

@media (min-width: 768px) { }
Expand Down
2 changes: 1 addition & 1 deletion tests/syntax_test_blade.blade.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* ^ - meta.embedded.blade source.blade meta.directive */
/* ^^^ keyword.control.directive.blade */
/* ^ punctuation.section.arguments.begin.blade */
/* ^^^^ source.php.embedded.blade constant.language.boolean.php */
/* ^^^^ source.php.embedded.blade constant.language.boolean */
/* ^ punctuation.section.arguments.end.blade */

var app = {{ Illuminate\Support\Js::from($array) }};
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.component.blade --}}
{{-- ^^^^^^^^ entity.other.attribute-name.component.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.component.blade --}}
{{-- ^^^^^^^ entity.other.attribute-name.component.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 --}}
Loading