NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Mixed Javascript and PHP in one file


Joined: 16 Aug 2008
Posts: 29
Reply with quote
I have a file which is 95% Javascript and the rest is some PHP code (enclosed in <?php ?>). For technical reasons I need the file to have the extension .php and the problem is that I would like the file to be syntax highlighted as Javascript code. As a matter of fact I don't really care about highlighting the small part of PHP code in that file, so all I'd be happy with forcing that single .PHP file to highlight as Javascript.

I understand that I have to set in file associations that Javascript has extension *.php, but that actually does nothing (dynamic highlighting seems to have no effect too). So far it only works when I remove the .php extension from PHP type association. Suprisingly - the PHP files still seem to highlight as PHP, but then I do feel I'am doing something horribly wrong ;)

Any ideas on how this can be solved?

Regards,
Ondrej
View user's profileFind all posts by odinuvSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
{PHP} line in associations assigns HTML+CSS+JS+PHP chain to highlighter so it expects HTML everywhere form the beginning, CSS to be included in <style> tags and JS included in <script> tags. All code included in <?php ?> is always treated as PHP.
{JS} line assigns JS+PHP chain to highlighter so it expects JS everywhere except <?php ?> tags.
So it's nothing wrong in your case, but... it changes associations for all files in all the projects.
We'll improve this in one of the future versions.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Aug 2008
Posts: 29
Reply with quote
dmitri wrote:
{PHP} line in associations assigns HTML+CSS+JS+PHP chain to highlighter so it expects HTML everywhere form the beginning, CSS to be included in <style> tags and JS included in <script> tags. All code included in <?php ?> is always treated as PHP.
{JS} line assigns JS+PHP chain to highlighter so it expects JS everywhere except <?php ?> tags.
So it's nothing wrong in your case, but... it changes associations for all files in all the projects.
We'll improve this in one of the future versions.


Thank you,
I gave it a try and as you say the code highlights correctly as you say. But then unfortunately the Code navigator switches to JS for all PHP files (i.e. it is not controlled by current syntax highlight but by file extension) - I know I can switch it manually to PHP but it will revert back to JS as soon as I click in the code it goes back to JS. So in the long run this doesn't really work well.
Thanks for trying, I'll cope with it - it is not that big issue, I just thought that maybe missed some feature of PhpED which already solves the problem.

Regrards,
Ondrej
View user's profileFind all posts by odinuvSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
[quote="odinuv"]
dmitri wrote:
Thanks for trying

There is no reason for me to try anything, so I didn't. I just explained you how it works.
Regarding dynamic highlighting - your can turn it on and off if you wish.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Mixed Javascript and PHP in one file
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