Code formatter breaks when escaping PHP inside JavaScript
8 posts
• Page 1 of 1
Code formatter breaks when escaping PHP inside JavaScript
Hi guys,
I'm having a few problems with some of my PHTML view scripts. I use the PHP editor to edit them as they can contain PHP but are mostly HTML and JavaScript. From memory this used to work fine in VS2015.
However, VS2017 is giving me a nasty error when I try and do something like the following:
When I run the formatter I get the following error popup:
Object reference not set to an instance of an object.
This is the simplest form of the code required to get it to break. Also syntax coloring no longer works. If I remove the PHP escape section then both the HTML and JavaScript syntax coloring works and I no longer get the error dialog. So it's the "<?=$testvalue;?>" breakout to PHP that is causing a problem.
Side note: JavaScript intellisense doesn't work inside <script> tags? Not a big issue. Just wondering if it's supposed to.
As always, thanks for the efforts. Let me know if you need any more info.
I'm having a few problems with some of my PHTML view scripts. I use the PHP editor to edit them as they can contain PHP but are mostly HTML and JavaScript. From memory this used to work fine in VS2015.
However, VS2017 is giving me a nasty error when I try and do something like the following:
- Code: Select all
<h1>Test Code</h1>
<script>
var test = '<?=$testvalue;?>';
</script>
When I run the formatter I get the following error popup:
Object reference not set to an instance of an object.
This is the simplest form of the code required to get it to break. Also syntax coloring no longer works. If I remove the PHP escape section then both the HTML and JavaScript syntax coloring works and I no longer get the error dialog. So it's the "<?=$testvalue;?>" breakout to PHP that is causing a problem.
Side note: JavaScript intellisense doesn't work inside <script> tags? Not a big issue. Just wondering if it's supposed to.
As always, thanks for the efforts. Let me know if you need any more info.
-
jazz - Posts: 41
- Joined: August 25th, 2016, 1:59 am
- Location: Canberra, Australia
Re: Code formatter breaks when escaping PHP inside JavaScrip
Hello Jazz,
Thanks again for your feedback.
These are several issues with VS2017 (vs2015 is fine):
1.) Javascript language service is not enabled in php editor in VS2017 due to bug on Microsoft end. They are working on it, but currently it's not clear when it's going to be out.
2.) Syntax highlighting of JS works without php code in it. We have solution for this (smart template already has that), but to employ it in php we need to wait for solution for issue #1.
3.) Object reference not set to an instance of an object during formatting. I'm going to take a look at this one and get back to you.
Thank you very much for your continuous feedback!
Thanks again for your feedback.
These are several issues with VS2017 (vs2015 is fine):
1.) Javascript language service is not enabled in php editor in VS2017 due to bug on Microsoft end. They are working on it, but currently it's not clear when it's going to be out.
2.) Syntax highlighting of JS works without php code in it. We have solution for this (smart template already has that), but to employ it in php we need to wait for solution for issue #1.
3.) Object reference not set to an instance of an object during formatting. I'm going to take a look at this one and get back to you.
Thank you very much for your continuous feedback!
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbeno │ miloslav@devsense.com
-
Miloslav Beno - Posts: 1252
- Joined: January 7th, 2012, 8:36 pm
Re: Code formatter breaks when escaping PHP inside JavaScrip
Thanks for the update.
I'm actually using this extension every day to help me develop my PHP MVC framework, Hazaar MVC, and I find it an invaluable tool. Just let me know if I get too annoying. haha.
Thanks.
I'm actually using this extension every day to help me develop my PHP MVC framework, Hazaar MVC, and I find it an invaluable tool. Just let me know if I get too annoying. haha.
Thanks.
-
jazz - Posts: 41
- Joined: August 25th, 2016, 1:59 am
- Location: Canberra, Australia
Re: Code formatter breaks when escaping PHP inside JavaScrip
Hi Jazz,
hehe, no wories. We love feedback, so please continue
So far we haven't been able to replicate issue #3, does this happen all the time or in some specific file?
Thanks!
hehe, no wories. We love feedback, so please continue
So far we haven't been able to replicate issue #3, does this happen all the time or in some specific file?
Thanks!
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbeno │ miloslav@devsense.com
-
Miloslav Beno - Posts: 1252
- Joined: January 7th, 2012, 8:36 pm
Re: Code formatter breaks when escaping PHP inside JavaScrip
To get that error to pop up, all I have to do is create a new file that is opened by the PHP editor. For me, this is my .phtml view files. But it also does this by creating a new PHP class and just putting this in the content:
Then run the code formatter (CTRL-SHIFT-K for me, or Edit/Advanced/Format Document) and you should see the message error dialog. This happens consistently when ANY PHP code is added inside JavaScript code.
Thanks.
- Code: Select all
<script>
var test = '<?=$thing;?>';
</script>
Then run the code formatter (CTRL-SHIFT-K for me, or Edit/Advanced/Format Document) and you should see the message error dialog. This happens consistently when ANY PHP code is added inside JavaScript code.
Thanks.
-
jazz - Posts: 41
- Joined: August 25th, 2016, 1:59 am
- Location: Canberra, Australia
Re: Code formatter breaks when escaping PHP inside JavaScrip
Any news on the javascript problem?
I have the same problem in many view files.
The way it is right now is almost unusable.
Not only that the javascript language sevice does not work but even simple formatting like manual tab indent isn't working.
This makes editing files a pain.
I have the same problem in many view files.
The way it is right now is almost unusable.
Not only that the javascript language sevice does not work but even simple formatting like manual tab indent isn't working.
This makes editing files a pain.
- info@dotcompanion.de
- Posts: 4
- Joined: September 17th, 2018, 6:13 pm
Re: Code formatter breaks when escaping PHP inside JavaScrip
Hi guys,
Thank you for noticing. We are currently investigating this. We suspect recent VS update caused this behaviour. I will notify you once I know more.
Thanks
Thank you for noticing. We are currently investigating this. We suspect recent VS update caused this behaviour. I will notify you once I know more.
Thanks
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbeno │ miloslav@devsense.com
-
Miloslav Beno - Posts: 1252
- Joined: January 7th, 2012, 8:36 pm
Re: Code formatter breaks when escaping PHP inside JavaScrip
I'm having the same problem. I also noticed that the JavaScript code coloring goes away too. All the JavaScript is white.
Is there any update to this problem?
Thanks,
Jeffery
Is there any update to this problem?
Thanks,
Jeffery
- JefferyS
- Posts: 4
- Joined: March 15th, 2017, 1:45 am
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests