Home Download Buy Blog Forum Support

PHP embedded inside JavaScript is not displayed correctly

PHP embedded inside JavaScript is not displayed correctly

Postby bobef on Thu Dec 13, 2012 2:46 pm

For example if we have a PHP file like this, the PHP tags inside the JS strings are not colored correctly and instead they are shown as if they are part of the JS string.

test.php:
Code: Select all
<script type="text/javascript">
require.config({
         paths: {
            "jquery": "jquery.<?= ENVIRONMENT == 'development' ? 'dev' : 'min' ?>"
         }
      });
</script>


Regards.
bobef
 
Posts: 26
Joined: Tue Nov 20, 2012 7:16 am

Re: PHP embedded inside JavaScript is not displayed correctly

Postby agibsonsw on Thu Dec 13, 2012 3:07 pm

This is: PHP/HTML > JS > string > PHP and the current scoping rules don't get beyond the 'string' aspect. Even if you create a separate .js file and use (proper) delimiters <?php ... ?> it still won't be scoped fully.

I managed to colour PHP within HTML (screenshot) but that's as far as I pursued this.
Attachments
scopephp.png
scopephp.png (25.08 KiB) Viewed 576 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PHP embedded inside JavaScript is not displayed correctly

Postby agibsonsw on Thu Dec 13, 2012 3:12 pm

Code: Select all
      <dict>
         <key>name</key>
         <string>Embedded begin (PHP)</string>
         <key>scope</key>
         <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.begin.php</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Embedded end (PHP)</string>
         <key>scope</key>
         <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.end.php</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Embedded PHP in HTML double</string>
         <key>scope</key>
         <string>text.html.basic meta.tag.inline.any.html string.quoted.double.html source.php.embedded.line.html</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Embedded PHP in HTML single</string>
         <key>scope</key>
         <string>text.html.basic meta.tag.inline.any.html string.quoted.single.html source.php.embedded.line.html</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>
        <dict>
            <key>name</key>
            <string>Embedded PHP in HTML (functions)</string>
            <key>scope</key>
            <string>text.html.basic source.php.embedded.block.html support.function</string>
            <key>settings</key>
            <dict>
                <key>fontStyle</key>
                <string></string>
                <key>foreground</key>
                <string>#FFFF00</string>
            </dict>
        </dict>
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 6 guests