Injection Language - lost Language

Hi,

I have this:

$css = '
               .CuContactErrorField {
                    border-color: #AA0000;
                }

                #CuContact_errormsg {
                    display: none;
                    border: 1px solid #BB0000;
                    padding: 7px;
                    margin: 25px 0 30px 0;
                    width: 396px;
                }
';

You see, it is CSS-Script in an php-variable. But when I tell phpStorm, that it is CSS it works for a litle time. But when I go to an other part of the code, an then back to this variable, phpStorm did forget, that it was CSS-Code.
Is it possible that I need to tell phpStorm that one only  time?

With JavaScript i have the same Problem.

Thank you,

cu

12 comments
Comment actions Permalink

Hi Jorg,

I've no idea why language injection is dropped (if you were not closing the file/restarting PhpStorm then maybe it worth reporting to the Issue Tracker for further investigation). But you can use this approach for a permanent injection:

$css = <<<CSS
    .CuContactErrorField {
        border-color: #AA0000;
    }
    
    #CuContact_errormsg {
        display: none;
        border: 1px solid #BB0000;
        padding: 7px;
        margin: 25px 0 30px 0;
        width: 396px;
    }
CSS;

0
Comment actions Permalink

Manual injections are by definition temporary.

The only way to have a persistent injection for a PHP string literal now is to use one of predefined "trigger patterns" - see Settings|Langiage Injection.

For css corresponding pattern is to use heredoc named CSS.

We have plans to inroduce other ways for more complex cases, but <<<CSS remain most non-intrusuve, self-documenting and does not require any storm-specific code annotations.

0
Comment actions Permalink

Hi thank you very much (Both).

That was what I'm looking for.

I needed a litle time to understand that the end oft such part (the pattern, that shows phpStorm to stop) has to be the first sign in the line.

Thank you

0
Comment actions Permalink

Thank you!

Thats nice

0
Comment actions Permalink

Hi,

Now if worked a litle bit with thes heredoc...

But know if have a nother (litle) problem with code-completition.

I have this:(press STR+SPACE on Courserposition)


____________no.png


I want this:

____________ok.png

Is it a BUG? -  or is it implementet? Or is it switchted off in my Settings?

###

I have just seen, the same Problem is, when I have code in normal " (not heredoc).

cu

0
Comment actions Permalink

Hi Jorg,

Did you attached images or something? Because I see nothing - current text (what I see) does not make much sense to me.

0
Comment actions Permalink

Hi,

did you see my update (i think, now the pictures must be shown)

Thank you

cu

0
Comment actions Permalink

Hi,

Works for me:
screen01.png
Maybe you have injected the wrong language? Use Alt+Enter and see what language is injected.

0
Comment actions Permalink

Hi,

Language Injection is HTML

You can see my Settings here:

___________________now.png

But it doesn't work for me.

?

cu

0
Comment actions Permalink

Hi, Jörg! Could you please report this problem to YouTrack: http://youtrack.jetbrains.com/dashboard#newissue=yes
It would be very helpful if you attach your file in which HTML injections don't work.

0

Please sign in to leave a comment.