Supplying PHP Storm with a list of data attributes for code completion?

Is there any way to supply PHPStorm with a list of data attribtues to use for code completion in HTML?

A lot of frameworks use data attributes extensively, and it would be nice to have easy access to the attributes used.

Thanks,

0

You can add all your data attributes to 'Custom HTML tag attributes' list  in Settings/Editor/Inspections/HTML/Unknown HTML tag attribute: attributes from  this list will be shown up in completion list and not reported as not  allowed

1
Avatar
Permanently deleted user

Much thanks!

0

I have several custom HTML tags that are used by the framework. Specifically, e.g.

<input data-onchange="foo.bar.baz">

means that the tag will generate a call to a Javascript function upon change, and more importantly, that the call will be to the foo.bar.baz() object.

It would be therefore great if I could click on the “bar” section of the HTML data-attribute and be sent to the file defining that particular Javascript data object, or on “baz” and be taken to the function body.

To do so, I enter

Settings > Editor > Language Injections

and add a new XML injection:

Name:           dataOnChange {or whatever, I guess}
Language:       ID = javascript (JavaScript)
XML Attribute:  Local name: data-onchange

All other fields blank. OK, Apply, and my tag is now clickable and working.

0

请先登录再写评论。