Language injection

In view used the following syntax to add JavaScript:

<?php

...skiped...
<?php $this->dojo()->javascriptCaptureStart(); ?>

     function someFunction() {
          alert('this is some function');
     }

<?php $this->dojo()->javascriptCaptureEnd();?>
...skiped...


How can i enable javascript code highlighting?

I trying do it via settings section "Language injections". But I do not understand how to do it.
Can anyone to explain me how do it? I think it will better to look at step by step example :)

5 comments
Comment actions Permalink

Hi Anton,

  1. Please provide simple but complete file example (so it can be copy-pasted for testing).
  2. What the file name? To be precise -- what extension and to what file type it is assigned in PhpStorm (Settings | File Types).


Right now (based on your code example) I assume that it is PHP file (somefile.php) but whole file is actually JavaScript (well, it will be JS file once processed by PHP interpreter at run time). If so -- then you should look at Settings | Template Data Languages -- find the file and assign JavaScript to it in 2nd column (Language Injection is a completely different thing -- is to inject another language into some variable/string ro similar code fragment but not to whole file.

0
Comment actions Permalink

I attached file. But it only for example. Because it's require framework for working.
It's php file. And all between <?php $this->dojo()->javascriptCaptureStart(); ?> and <?php $this->dojo()->javascriptCaptureEnd();?> is javascript. I think is language injection into php file.



Attachment(s):
a.phtml.zip
0
Comment actions Permalink

Hi Anton,

I don't think you can do it with such messy structure where HTML is mixed with JavaScript directly, with no <script> tags (using <?php $this->dojo()->javascriptCaptureStart(); ?> as opening <script> tag equivalent does not work here). Language Injection functionality requires some anchors/patterns (like aforementioned <script> tag, for example, where it should work straight away without any additional moves).

If you need to edit JavaScript code only (temporarily ignoring HTML errors), then you can try my original thought (Settings | Template Data Languages) -- it should give you JavaScript syntax highlighting and code completion (to a some degree, of course).

0
Comment actions Permalink

But if you use Zend framework with dojo it's standard practic of javascript decorate.
See http://framework.zend.com/manual/en/zend.dojo.view.html

And instead of "<script>" and "</script>" in views i must use "$this->dojo()->javascriptCaptureStart(); ?>" and "$this->dojo()->javascriptCaptureEnd(); ?>".

Have any solution to enable right highliting of javascript? Many use Zend framework and i think they need it.

0
Comment actions Permalink

I think the final answer may be the same as in this thread ( http://devnet.jetbrains.net/thread/434025?tstart=0 ) -- it was 2nd or 3rd from the top when you created yours, so you may have seen it already. The requirements there ({js}{/js}) are simpler but still "too much" for current implementation.

I guess (I hope), that when these tickets will be implemented ( WI-1063, WI-9606 ) it will be possible to implement your requirements as well (if IDE will provide full support for Zend Framework, then it should allow such Language Injections as well, right?).

I think it will not hurt if you submit a new ticket for Feature Request on Issue Tracker to make sure that it will be implemented (at very least considered) as well during implementing of the aforementioned tickets.

0

Please sign in to leave a comment.