I am having PHP code inside my JavaScript file, which is processed by the server by setting the handler for the .js file extension to php5-script
using a .htaccess
. I tried opening the .js file in Aptana Studio using PHP Source Editor and JavaScript Source Editor, however, both editors highlight the php code as syntax error. I couldn't find an option in the settings where I can set the file type to a mix of PHP and JavaScript, or disable syntax error highlighting for PHP code in JavaScript, or anything else.
I have found a similar question but this is just related to the PHPStorm IDE which I do not want to use.
The content of my .js file currently looks like this:
<?php
header('Content-type: application/javascript');
$app_base_path = $_GET['_app-base-path'];
$app_route = $_GET['_app-route'];
?>
$(function() {
var APP = {
// syntax errors are thrown here
// the single quotes could be escaped to reduce syntax errors
// looking for a way to make a code like this possible without any syntax errors
base_path: '<?= $_GET['_app-base-path'] ?>',
route: '<?= $_GET['_app-route'] ?>'
};
$('body').append('APP.base_path: ' + APP.base_path + ' --- APP.route: ' + APP.route);
});