What settings to allow PHP inside JS files without breaking inspection

Hello,

We're coming from a PHPEd background where they have an option to parse JS files with PHP. They call this setting "Parse PHP in CSS files".

We have js and CSS files which have PHP in them, and when we load up these files PhpStorm litters the right bar with tons of errors.

Any tips or settings we could tweak to help this?

6 comments
Comment actions Permalink

Step one: Settings|File types -> move .css to PHP file type
Step two: Settings|Template Data languages -> set CSS as "outer" language for these php files.

0
Comment actions Permalink

Thanks for the reply, but when I follow those steps PHPstorm tried to reparse the directories for 30 minutes before I killed the process.  I'm guessing this makes PhpStorm treat all the js and CSS files as PHP files to parse for inspections, autocompletions, etc?

0
Comment actions Permalink

Yes.
But unless you map dedicated extensions for php-in-js or other - there's no way to avoid parsing of all js files.

0
Comment actions Permalink

Is there any way to set a default template data language for a given extension?  Or for a directory tree?  Basically, the problem I'm running into is that I need to now go into settings and manually set the template data language for every javascript file now.  I'd like a way to speed this process up.

Thanks,
Anthony

0
Comment actions Permalink

Upon further thought, ideally I would be able to set PHP as the "inner language" for the entire project and allow the existing file extension assignments to define the outer language.

0
Comment actions Permalink

feel free to file a feature request, but its really unlikely to be implemented in any near future.

0

Please sign in to leave a comment.