我如何告诉Netbeans一段代码是Javascript? [英] How do I tell Netbeans that a section of code is Javascript?

查看:71
本文介绍了我如何告诉Netbeans一段代码是Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Zend Framework的javascript帮助形式:

I'm using the Zend Framework's javascript helpers of the form:

<?php $this->headScript()->captureStart(); ?>
//Javascript here
<?php $this->headScript()->captureEnd(); ?>

//Rest of view here

问题是Netbeans一直在抱怨关于块中的代码问题,因为它认为它是一个HTML,而不是一个Javascript,块。加上语法着色被打破了。

The problem is that Netbeans keeps complaining about code problems in the block, because it thinks it's an HTML, rather than a Javascript, block. Plus syntax coloring is broken.

Netbeans已经有一个特殊的评论提示,当Netbeans无法自动解析时,你可以使用它来将一个类型应用于变量它是我们在那个范围内编写Javascript而不是HTML吗?

Netbeans already has special comment hinting which you can use to apply a type to a variable when it can't be resolved by Netbeans automatically to tell it that we're writing Javascript in that range, rather than HTML?

推荐答案

这样的事情:

<?php  $this->headScript()->captureStart(); ?>
//<script type="text/javascript">
var validJSsyntax = true,
    netbeansJShighlighting = true,
    problem = 'solved';
//</script>
<?php $this->headScript()->captureEnd(); ?>

当然它会在你的JS输出中产生两条无用的行,但你可以修改 captureEnd()为你去掉那些的方法。

Of course it will produce two useless lines in your JS output, but you can modify captureEnd() method to strip those for you.

这篇关于我如何告诉Netbeans一段代码是Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆