File templates are used by the wizards in the New File wizard, when you create new files. For example, when you create a new JSP in the New File wizard, the wizard takes the values you fill in (such as the JSP name) and inserts them into the JSP file template, resulting in a JSP file with the name you specified.
The IDE comes with a set of predefined file templates, which you can see in the Templates Manager, under the Tools menu. You can modify most of these file templates and you can add your own too.
For example, this is how the Java Class template that comes with the IDE is defined:
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
*/
public class ${name} {
}
Above, you can see tags like <#if>, which are FreeMarker directives. Here is a complete list:
Use FreeMarker directives to add logic to your templates. For details on the FreeMarker directives, see the FreeMarker Directives chapter and the Directive Reference in the FreeMarker Manual.
You do not HAVE TO use FreeMarker. Doing so only makes sense if you want to add logic (i.e., if/else/loops/etc) to your file templates. FreeMarker is there to help you. It isn't there to make your life more complex. Use it as needed, otherwise ignore it.
Applies to: NetBeans 6.x
Platforms: All