Template Languages: Velocity and FreeMarkerUltimate
IntelliJ IDEA lets you develop templates in Velocity and FreeMarker template languages (VTL and FTL). Coding assistance and syntax highlighting is provided using corresponding plugins, which are enabled by default.


The following file types are supported by default:
VTL | .ft, .vm, .vsl |
FTL | .ftl, .ftlh, .ftlx |
To enable coding assistance for languages in which the static part of the template is written (those are referred to as template data languages ), do one of the following:
Fixing unresolved references
IntelliJ IDEA provides inspections for detecting unresolved references in template languages:

Unresolved references can be fixed using intention actions. You can select to add a comment in the same file, or to create a separate file with comments. For more information, see Special comments.

note
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. This file starts with the following comment:
#* @implicitly included *#
Code completion for defining reference types is available in the comments files.

If you rename the file or move it to a different location within the source root, reference definitions will not be lost.
Special comments
IntelliJ IDEA provides the following special comments for working with template languages:
FreeMarker comments are delimited using either <#--
and -->
or [#--
and --#]
.
Comment | Description |
---|---|
@implicitly included | Any FreeMarker file that starts with this comment is included into all files that are in the same module or its dependencies. Use such a dedicated comments file to define IDE-specific comments, so that they do not pollute your template files. |
@ftlvariable | Defines a variable. For example, the following comment declares a variable named foo of type String , visible only in the specified file:
String in this case, the module should have JDK attached. Primitive and generic types are supported. The file parameter is optional. |
@ftlroot | Defines the path relative to which import and include directives are resolved. The path is specified relative to any of the directories in the current FTL file's package. Paths inside JARs are also supported, for example:
|