Interpret `<script type="x-magento-init">` as JSON syntax
See original GitHub issueIs your feature request related to a problem? Please describe.
I would like to get the validation of the <script type="x-magento-init">
as JSON in PHPStorm
Describe the solution you’d like (*)
When I create node <script type="x-magento-init">
I would like to get this validated as a JSON syntax, as well as have hints provided.
Describe alternatives you’ve considered
Manual configuration of PHPStorm.
Additional context
We can also cover data-mage-init
too
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Calling and initializing JavaScript - Magento DevDocs
To call a JS component on an HTML element without direct access to the element or with no relation to a certain element,...
Read more >unexpected SyntaxError from Template/Ajax - Magento 2
I am a newby in Magento, so sorry if my question seem stupid. I have an error. SyntaxError: JSON.parse: expected double-quoted property name ......
Read more >How to fixed Uncaught SyntaxError: Unexpected token } in ...
Magento page console error Uncaught SyntaxError: Unexpected token } in JSON at position 530 while you have made mistake to your code.
Read more >Magento 2: how to debug json error - Valuable Tech Notes
The only JSON.parse command in main.js is in the getData function; specifically, ... script into a template file, but that the attribute's JSON...
Read more >Magento 2 Certified Professional JavaScript Developer Guide
Magento makes use of this behavior peculiarity and, after the page is loaded, uses JSON-content of such tags for initialization and launch of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, @DmitryFurs, @ihor-sviziev, @dkorpar, @VitaliyBoyko, @andrewbess, @coderimus, @Iamwade!
We have added missed check if the Magento 2 integration is enabled (it will be included in the next release, 4.3.0. For now with plugin installed highlighting will work even if Magento 2 integration is disabled for a project).
Please, help us to decide, if we need to add separate ability to enable/disable uiComponent script highlighting if magento integration is enabled.
Please, use 👍 to approve this idea and 👎 to leave highlighting enabled just if integration is enabled.
Regards,
@coderimus any updates?
By default now it looks like this
But if we configure the inspection that @dkorpar described, then if there is php code inside, we get the following situation
In case where the php expression is wrapped in double quotes these errors disappear
Also, ctrl+click to jump to the reference only works in the case of wrapped quotes. But quotation marks are not always necessary, for example, if we want to pass a strictly numeric value, or a boolean value
true
orfalse
.