-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
PHP injection inside :attribute="php_only"
#33
Comments
The way I look at this, there's two ways to go about this:
|
@calebdw I had your option 2 in mind myself. Basically define In terms of highlighting, users then having the freedom to either paint them as I haven't had a chance to give it a shot yet. It might be easier said than done when it comes to regex haha. But we shall see! I have a feeling the I had the same idea for #28 but I think it would be easier for that, because it's just a simple regex, I am not aware of any other framework using a similar syntax? |
It's not that simple---those injections are only valid inside a blade component element which you would have no way of knowing without copying a lot of the html parser to determine what's an element, attribute, etc. The simplest thing to do is to just extend the default html injections, the below html injections solves this issue, #28, and #34 without any changes needed to the blade parser:
;; extends
; AlpineJS attributes
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^x%-%l")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; Blade escaped JS attributes
; <x-foo ::bar="baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^::%l")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))))
; Blade PHP attributes
; <x-foo :bar="$baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^:%l")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "php_only")))) |
Add support for php injection inside
:attribute
directivessee Passing Data
The text was updated successfully, but these errors were encountered: