Home Download Buy Blog Forum Support

How can PHP code inside Javascript string be highlighted?

How can PHP code inside Javascript string be highlighted?

Postby singw on Tue Jun 19, 2012 3:25 am

The PHP code within Javascript's string is not highlighted as PHP syntax. As show in the attached screenshot.
Is is possible to make it correctly highlighted?
Attachments
sublime-js-php-syntax-highlight.png
sublime-js-php-syntax-highlight.png (37.01 KiB) Viewed 1032 times
singw
 
Posts: 59
Joined: Fri Aug 05, 2011 2:16 pm

Re: How can PHP code inside Javascript string be highlighted?

Postby atomi on Tue Jun 19, 2012 6:19 am

It is possible. You would need to either edit the javascript.tmlanguage file and declare a rule that matches <?php (.*) ?> within a string or create a new tmlanguage file that matches strings with php code in it and include the source.js.

The part you want to edit is line 409 to line 474 in Javascript.tmLanguage. Just include the rule for <php tags in both string.quoted.double.js and string.quoted.single.js.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: How can PHP code inside Javascript string be highlighted?

Postby Pwarts on Wed Nov 07, 2012 3:13 pm

Would anyone mind spelling this out for me?

I've opened up javascript.tmlanguage but I'm really not sure how to declare the rule.

Thanks
Pwarts
 
Posts: 3
Joined: Wed Nov 07, 2012 3:10 pm

Re: How can PHP code inside Javascript string be highlighted?

Postby epidose on Sun Nov 11, 2012 12:04 pm

Anyone got a proper fix for this? I just started using sublime and have been trying to fix this in the language files for hours. Looks like it would be quite a common syntax... N++ handles it just fine
epidose
 
Posts: 1
Joined: Sun Nov 11, 2012 12:01 pm

Re: How can PHP code inside Javascript string be highlighted?

Postby gacosta on Fri Nov 30, 2012 4:34 pm

I was going to start using sublime text instead of zend studio today on linux but this stoped me, in my case it was in html though, ¿perhaps they should include this option from scratch in js as well as in html?
gacosta
 
Posts: 1
Joined: Fri Nov 30, 2012 4:32 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 20 guests