How do I tell Netbeans that a section of code is Javascript?

前端 未结 4 958
旧时难觅i
旧时难觅i 2021-01-23 04:11

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

headScript()->captureStart(); ?>
//Javascript here
h         


        
相关标签:
4条回答
  • 2021-01-23 04:53

    I was actually just reading about this yesterday in their blog:

    Their HTML in PHP parsing has been flaky, especially with indenting incorrectly short/alternate form code, but the latest nightly builds (I presume those after 201010060000) have improvements in that area. I haven't tried it yet but give it a shot.

    0 讨论(0)
  • 2021-01-23 05:08

    Something like this:

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

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

    0 讨论(0)
  • 2021-01-23 05:10

    print problematic code with PHP

    <script <?PHP echo 'type="text/template"?> id="Template-1">
        //your code here
    </script>
    

    If you print all script tag with PHP, NetBeans perfectlly format HTML tags

    0 讨论(0)
  • 2021-01-23 05:14

    From my knowledge this functionality is not yet implemented in the current version of NetBeans IDE that is 6.9.1. I can show you a workaround through which you can fool the NetBeans IDE to highlight the Javascript as a script section, and also keeps the PHP processor happy. It will look like following code snippet:

        <?php $this->headScript()->captureStart(); ?>
        <?php if( false ) {?><script><?php } ?>
            // keep Javascript here
        <?php if( false ) { ?></script><?php } ?>
        <?php $this->headScript()->captureEnd(); ?>
    

    I have tested this in NetBeans IDE 6.9.1

    0 讨论(0)
提交回复
热议问题