Download NetBeans!

20071001 Monday October 01, 2007

FreeMarker Fun Pack

My nascent interest in FreeMarker has resulted in the 2.0 version of the FreeMarker Plugin that I talked about some days ago. Do the following if FreeMarker is also something that you consider a fun deal:

  1. Download and install the plugin, in 6.0 Beta 1 or some recent 6.0. In the Plugin Manager, you'll see this:

  2. In the New Project wizard, you'll find the sample in the Samples | NetBeans Modules category:

    Finish the wizard shown above.

  3. Now you have a module project. Install it somewhere (either in the current IDE or in some other target NetBeans Platform). Now you have very gentle FreeMarker syntax coloring, code completion, and navigator support for all files with either the "ftl" or "template" extension:

    Note: The first time you call up code completion under Schliemann, per session, it is very slow.

  4. Don't like the colors? That's okay too. Go to the Options window (under the Tools menu) and change the colors:

  5. There are several file templates available, as you can see here:

The most interesting thing to do with this plugin is, assuming you're a developer on the NetBeans Platform who needs to let the user generate code, to look in the layer.xml file. Look at the Templates section, especially the definition of the two wizards. You'll see how a wizard is able to generate from a FreeMarker template, by referencing the template in the URL attribute, in combination with setting the FreeMarker scripting engine element.

The syntax coloring is based on code I found in the NetBeans sources. Until we officially support FreeMarker in the editor, this is the plugin that I will be using. Have fun with it. FreeMarker is really an incredibly cool way to generate code, as my blog entry yesterday went some way to show.

Oct 01 2007, 08:54:48 AM PDT Permalink