IntelliJ IDEA 2016.2 Help

Template Languages: Velocity and FreeMarker

On this page:


IntelliJ IDEA lets you develop templates in Velocity and FreeMarker template languages (VTL and FTL).

Coding assistance for VTL and FTL is available for files whose file name extensions match the extension patterns associated with the Velocity Template and FreeMarker Template file types. By default, those are *.ft, *.vm and *.vsl for Velocity and *.ftl for FreeMarker.

To get coding assistance also for the languages in which the static part of the template is written (those are referred to as template data languages), you should do one of the following:

  • Associate the template data languages with files and folders in your project. In this way you specify where in your project you need coding assistance for the corresponding template data languages.
  • Add your own extension pattern for the Velocity Template or FreeMarker Template file type and associate that extension pattern with the necessary template data language.

Associating template data languages with files and folders

  1. Open the Settings / Preferences dialog (e.g. Ctrl+Alt+S).
  2. Go to the Template Data Languages page: Languages and Frameworks | Template Data Languages.
  3. Click the Template data language cell to the right of the project, or the corresponding directory or file, and select the language.
  4. Click OK in the Settings / Preferences dialog.

Individual template files can be assigned a template data language right in the editor. There is the Change template data language to context menu command for that.

Creating an extension pattern for a template data language

  1. Open the Settings / Preferences dialog (e.g. Ctrl+Alt+S).
  2. Go to the File Types page: Editor | File Types.
  3. Under Recognized File Types, select FreeMarker Template or Velocity Template.
  4. In the Registered Patterns section, click add.
  5. In the Add Wildcard dialog that opens, specify the file name extension pattern and select the language.
  6. Click OK in the Settings / Preferences dialog.

Using code completion

IntelliJ IDEA provides code completion for the template language elements such as directives, variables, built-ins, etc.


Fixing unresolved references

IntelliJ IDEA provides inspections for detecting unresolved references.


The unresolved references can be fixed by means of intention actions. You can select to add a comment in the same file, or to create a separate file with comments. (Comments in such cases are used to provide missing info about the references.)


In the latter case, a file with the default name velocity_implicit.vm or freemarker_implicit.ftl is created. The file starts with the comment

#* @implicitly included *#

To define reference types, code completion is available.


At a later time, you can rename the file, or move it to a different location within the source root, and the reference definitions will not be lost.

See Also

Last modified: 23 November 2016