Is there a way to use multiple languages in a single PhpStorm file?

I am having trouble getting a single file to do proper highlighting/hinting/linting for all these languages at once: PHP, XHTML, Twig, SCSS, JavaScript.

I put up a detailed on StackOverflow that might make things clear: 

I have a custom file extension, .sfc, that I have associated with PHP. PHP code is correctly recognized, as is XHTML, CSS, and JavaScript. The problem happens when I try to introduce Twig and SCSS. The Twig code is still treated as XHTML and the SCSS code is treated as CSS.

I have tried to figure out language injection comments, but I either don't understand them, or the built-in configurations don't handle Twig and SCSS inside of a PHP file.

Any suggestions on how I can trigger proper recognition fo all 5 languages in one file?

Comment actions Permalink

As I can see there's already a valid reply:

There are currently no other options to achieve that

Comment actions Permalink

Hi Dmitry, 

Thank you for reply. Since I posted the question, I learned a few more things.

It does appear that SCSS can be injected properly using <style type="text/scss"> instead of just <style> (which assumes CSS). JavaScript is of course already supported as <script>. So Twig is the only language missing from the mix.

I put in a feature request to make Twig an injectable language:



Please sign in to leave a comment.