Code formatter breaks when escaping PHP inside JavaScript
Posted: February 19th, 2017, 11:59 pm
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.