简体   繁体   English

如何使用PhpStorm IDE在CakePHP项目中正确识别js代码?

[英]How to correct identify js code in CakePHP project with PhpStorm IDE?

I am using Phpstorm as IDE in a CakePHP 3.0 project and the plugin CakeStorm. 我在CakePHP 3.0项目和插件CakeStorm中将Phpstorm用作IDE。 I would like to treat code inside script blocks as javascript code but the IDE doesnt identify with the correct syntax. 我想将脚本块中的代码视为javascript代码,但IDE不能使用正确的语法进行标识。

<?php $this->start('script') ?>
  //javascript code here ...
<?php $this->end() ?>

I know there is a feature called "language injection" in PhpStorm that could solve the problem but couldnt figure out a way to achieve this. 我知道PhpStorm中有一个称为“语言注入”的功能可以解决此问题,但无法找到实现此目的的方法。

However, you can do that in php context: 但是,您可以在php上下文中执行此操作:

$this->start('script');
echo <<<JS 
    //javascript code here ...
JS;
$this->end();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM