NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to associate *.js.php files to Javascript?


Joined: 22 May 2010
Posts: 2
Reply with quote
How to associate *.js.php files to Javascript in order to get the JS syntax colors with PHP syntax colors.
I've tried to add *.js.php into Settings/Associations/JavaScript but this just don't work.
Anyone?
View user's profileFind all posts by svovafSend private message


Joined: 11 Apr 2010
Posts: 90
Location: Prague, Czech Republic
Reply with quote
Hello.

I don't think you can do that. The file asociations are mostly based on file extension, which is the string fragment after the LAST dot - that way an extension may be an empty string if there is no dot in the file name. This also means, that if you have file named 'myscript.js.php', then the file name is 'myscript.js' and the extension is 'php'. The '*.php' expression for file associations is just a common way, how to say "everything with 'php' extension". This is different from searching for "*.js.php" string, where the search engine is mostly based on regular expressions and understands, that you want to search "everything ending with '.js.php'". So unless you have a regular expression based file association, the '*.js.php' file association will not work, because simply put the extension 'js.php' can never exist.
View user's profileFind all posts by fibizaSend private message


Joined: 22 May 2010
Posts: 2
Reply with quote
O.K, so what can I do?
I have JavaScript files which has inner PHP code, but in order that the server will process those files using the PHP engine it must ends with ".php".
One way I can get the associated syntax colors is every time when I code some JS in such files, I can rename it to pure *.js extension, but this
is very annoying - renaming it every time I want to edit those files. Any other solution? hack? patch? trick? Smile
View user's profileFind all posts by svovafSend private message


Joined: 11 Apr 2010
Posts: 90
Location: Prague, Czech Republic
Reply with quote
If you just need to parse PHP code in JS files inside phpEd, there is an option for this in Tools -> Settings -> Code Insight -> Settings -> Parse PHP in JS files - check that option and that should do the trick.

But if you need the web server (like Apache) to parse PHP code inside JS files, you either need to change the server configuration to treat '.js' extension as PHP files or you can use '.htaccess' and mod_rewrite (for Apache servers). The second option is preferable, this way the JS file will not really exist, but the rewrite engine will redirect the file request to PHP script, which would create the JS file on the fly. You would need to google information elsewhere though, because this has nothing to do with phpEd (try google "mod_rewrite" and "htaccess" for details).
View user's profileFind all posts by fibizaSend private message
How to associate *.js.php files to Javascript?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic