简体   繁体   English

Eclipse中* .php文件中的Javascript突出显示

[英]Javascript hightlighting within *.php files in Eclipse

I have read other posts talking about the Aptana plugin with Eclipse PDT and I've installed it and still have no syntax highlighting of javascript within my php files. 我已经阅读了其他有关Eclipse PDT的Aptana插件的文章,并且已经安装了它,但在我的php文件中仍然没有语法突出显示javascript。

I have a php file with my php at the top if the form has been submitted and then the rest of the content is javascript/html, outside the php tags obviously. 如果表单已提交,则我的php文件位于顶部,而其余的内容是javascript / html,显然在php标签之外,我有一个php文件。 The html has syntax highlighting but I still have no syntax highlighting for the javascript. html有语法高亮显示,但是我仍然没有JavaScript的语法高亮显示。 I've added the Aptana JS editor to the *.php file types in the settings and still nothing. 我已经在设置中的* .php文件类型中添加了Aptana JS编辑器,仍然一无所获。

I have a feeling that it's defaulting to the PHPEclipse editor, which I guess doesn't support javascript syntax highlighting? 我感觉它默认为PHPEclipse编辑器,我猜它不支持javascript语法高亮显示? Any ideas or am I forced to make all of my javascript files external to the php file? 任何想法还是我被迫将所有JavaScript文件都置于php文件之外?

A PHP file like that will be a combination of four different editors: PHP, HTML, CSS, and JavaScript 这样的PHP文件将由四个不同的编辑器组成:PHP,HTML,CSS和JavaScript

PDT uses the Web Tools Projects (WTP/WST) for HTML, JS and CSS support. PDT使用Web工具项目(WTP / WST)获得HTML,JS和CSS支持。 It's impossible to use the Aptana HTML, CSS, or JS editors inside a file opened with the PDT PHP editor, so the level of support you get in PDT is completely dependent on the WTP editors. 在用PDT PHP编辑器打开的文件中不能使用Aptana HTML,CSS或JS编辑器,因此在PDT中获得的支持级别完全取决于WTP编辑器。 Your only solution there would be to externalize your JavaScript into a separate file, which you could open with the Aptana JavaScript editor. 唯一的解决方案是将JavaScript外部化为一个单独的文件,您可以使用Aptana JavaScript编辑器打开该文件。

Aptana Studio 2 used the PDT for PHP editing. Aptana Studio 2使用PDT进行PHP编辑。 Aptana Studio 3 bundles its own PHP editor, so you will get the combination of a PHP editor for the PHP-parts + Aptana support for HTML, CSS and JavaScript. Aptana Studio 3捆绑了自己的PHP编辑器,因此您将获得PHP编辑器的PHP部分组合+ Aptana对HTML,CSS和JavaScript的支持。

您可能无法在PHP编辑器中“激活”更好的JavaScript支持,因为它只是缺少支持问题。

Actually, you just need to open the file in the "PHP Source Editor" instead of the "PHP Editor". 实际上,您只需要在“ PHP Source Editor”而不是“ PHP Editor”中打开文件。 The former is from Aptana and provides the improved support for JS, plus allows you to use added jQuery bundles, while the standard (PDT-supplied) "PHP Editor" does have some features lacking in the Aptana version, but is generally trumped by Aptana. 前者来自Aptana,并提供了对JS的改进支持,并允许您使用添加的jQuery捆绑包,而标准(PDT提供)的“ PHP编辑器” 确实具有Aptana版本中缺少的某些功能,但通常被Aptana所取代。 We'll see where they go in the future, but Aptana has brought some nice features to the table. 我们将看到它们的未来发展方向,但是Aptana带来了一些不错的功能。

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

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