Twig for Netbeans

On this page I want to give you some information about my Twig plugin for Netbeans. It provides code highlighting and syntax validation for Twig and makes it a lot easier to write templates.

Features

  • Twig code highlighting
  • Configurable colors
  • Highlighting of underlying HTML markup
  • Syntax validation (unclosed blocks an so on)
  • Code folds

Links & Download

You can download the current stable package at the Netbeans plugin portal.

If you want to get the current development version, you can download it at Github. If you want to contribute or just see the source code you can visit the project page of Twig-netbeans at github.

23 thoughts on “Twig for Netbeans

  1. Hi,

    I’ve made a reinstall of netbeans and lost my twig plugin for nb 6.9. Is there a place where I can I find it in that particular version ? I don’t see it on the nb plugin portal and netbeans 7.0 isn’t working properly on my system, so I would like to switch back to my old configuration…

    Regards,

    Steve

    1. You could download the Netbeans developer package for your Netbeans version, load the source code from https://github.com/blogsh/Twig-netbeans and build your own plugin package. I’m not sure whether the plugin uses 7.0-specific stuff, but it’s worth a try. However, tell me if you can get it work. If not I’ll try myself, but at the moment I’m quite busy so it may last some days…

  2. Ok, thanks. I’ll give it a try this weekend, but I’m afraid it could exceed my abilities, as I’m just a poor PHP developer… ;).

  3. On clean istall NB 7.0 i get these errors after install:

    Warning – could not install some modules: SQL Editor – The module named org.netbeans.modules.editor.deprecated.pre65formatting/0-1 was needed and not found. Editor Formatting Prior 6.5 Separation – The module Editor Library 2 was requested in implementation version “8” but only “9” was found. Tags Based Editors Library – The module named org.netbeans.modules.editor.deprecated.pre65formatting/0-1 was needed and not found. XML Text Editor – The module named org.netbeans.modules.editor.deprecated.pre65formatting/0-1 was needed and not found. 17 further modules could not be installed due to the above problems.

    too bad, this is the only twig syntax plugin out there…

  4. Which version do you use? The one from the plugin portal or the git version? On which operating system do you have these errors?
    However the latest version on the plugin portal should work…

  5. I used the latest version from netnbeans portal. When this error occured, PHP files were no longer recognized (no specific language colors, autocomplete, error check etc.), after removing the plugin the error still occured, so I reinstalled Netbeans and installed again the Twig extension (clean install) – again the error occured. So reinstalled again netbeans… so I gave up. I am using Windows 7 Proffesional SP1 x64 and latest Netbeans 7.

    1. @geo Hi! I see you are right, the plugin fails to install and disables the PHP plugin on a fresh Netbeans installation. I’ve found the following workaround: When fresh Netbeans starts it will give you the advice to update some plugins. If you install the Twig plugin after you have updated the native plugins everything should work. :)
      I’m not quite sure why Netbeans won’t update to the latest versions when Twig is installed first, but I have to find out. Anyway thanks for your hint!

  6. Hi Sebastian,
    this solves the issue now it works OK :) (Clean install, update of all plugins and then – twig for neatbeans installation).
    Thanks for the plugin and the help!

  7. Thanks a lot, Sebastian !

    That’s exactly what I needed. Thanks for your work, and for having time to devote to users !

    Best regards,

    Steve

  8. Hi Sebastian

    Thanks for your work, it really works nice under Netbeans 7.0

    However, it seems that there is a bug that makes Netbeans hung up for some time.
    It happens when I type {} and then try to type %% inside {} to create Twig markers. Netbeans just hungs up and I have to kill the process or wait for a minute or so.

    Maybe this is difficult to fix as it seems that it starts looking for some autocompletion stuff.

    I am using Ubuntu Narwal x64 with Java 1.6.0_22 OpenJDK.

    Anyway thanks again for your hard work integrating this nice templating system into Netbeans IDE.

  9. Testing the latest stable plugin, we encountered both bugs with Netbeans 7:

    1. Using a fresh netbeans install, the plugin fails to install and disables several other plugins (i.e. the php plugin). Only a complete new installation of netbeans including an update of all plugins before installing the twigs plugin solved this.

    2. Typing a % inside of {} causes a freeze of netbeans (using Windows 7 and Mac OS X).

    Greats from Germany
    Jan

    1. Have you tried to install it in Nb7.1? Currently I’m working at my quite lame netbook where I have no Nb installed at the moment. But I think I used the plugin with Nb7.1 already on my desktop pc.

  10. Hi! I am looking for a RainTPL highlighting plugin for NetBeans, your project is very interesting. Would you put online the Antlr grammar for Twig, as it would be easy to adjust for RainTPL. Thanks!

  11. Hi Sebastian Hörl,

    How did you manage to do the twig parser and lexer, by hand-coding or you generated from ANTLR or JAVACC grammar?

    Can anyone help me on next step after generating the java files from ANTLR by compiling the .g4 grammars to integrate into netbeans module?

    Regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">