Sublime Forum

PHP embedded inside JavaScript is not displayed correctly

#1

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:

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

Regards.

0 Likes

#2

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.


0 Likes

#3

<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>

0 Likes