How to add a custom file extension that has a dot (blade.php) in NetBeans?

后端 未结 4 1893
旧时难觅i
旧时难觅i 2021-01-01 19:24

I need to assign a custom extension to be recognized as a twig file in netbeans (\'blade.php\' as \'twig\' file and give me syntax highlighting and code completion appropria

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 19:47

    Modify the user-defined-mime-resolver.xml file so that it looks something like this:

    
    
    
        
            
            
            
        
        
        
            
        
    
    

    On Linux (Ubuntu), you can find this file at:
    $HOME/.netbeans/8.2/config/Services/MIMEResolver/user-defined-mime-resolver.xml

    On Windows, you can find the file at: %AppData%\Netbeans\8.2\config\Services\MIMEResolver\user-defined-mime-resolver.xml

    Basically, the first block scans the filename of any PHP files to see if it contains the ".blade" substring. If so, the file is treated as a Twig file. If not, the second block will treat the file as a normal PHP file.

    You might need the "Twig Templates" NetBeans plugin in order to get proper highlighting:
    Tools > Plugins > Available Plugins > Twig Templates

    It's not perfect... Blade directives such as @include are still highlighted as plain text. However, I feel it is a marked improvement over PHP syntax highlighting.

    The following sources were extremely helpful:

    • HOW TO: Declarative MIME Type Resolvers
    • DTD Grammar Documentation
    • David Benedeki's earlier answer to this question

提交回复
热议问题