I have a JavaScript file that needs to have some PHP tags in it. Something like this:
var chart = {
init: function() {
...
drawChart(this.data);
...
},
data: <?php echo $this->data ?>
}
The output is obviously a pure JavaScript file and functionally this is working fine. However, IntelliJ isn't correctly highlighting the code. If I name the file with a .js extension, it starts showing errors as soon as it runs across a PHP tag. If I name the file with a .php extension, it doesn't show any syntax errors, but doesn't highlight any of the JavaScript, only the PHP.
I know it's capable of doing this because I can name the file with a .php extension and surround all the code with <script>
tags and everything highlights correctly. Unfortunately that would break my application.
Does anyone know of a way I can get highlighting to work for both languages without script
tags?