Overview
File templates are written in the
Velocity Template Language
(VTL). So they may include:
- Fixed text (markup, code, comments, etc.). In a file based on a template, the fixed text is used literally, as-is.
- File template variables. When creating a file, the variables are replaced with their values.
- #parse directives to include other templates defined in the Includes tab on the File Templates page of the Settings dialog box.
- Other VTL constructs.
Here is a typical template example. (This template is used for creating a JavaScript file.)
/**
* Created by ${PRODUCT_NAME}.
* User: ${USER}
* Date: ${DATE}
* Time: ${TIME}
* To change this template use File | Settings | File Templates.
*/
In this template, ${PRODUCT_NAME}, ${USER}, ${DATE} and ${TIME} are template variables.
Applying this template leads to generating a file whose contents look similar to this:
/**
* Created by RubyMine.
* User: John.Smith
* Date: 6/7/11
* Time: 4:17 PM
* To change this template use File | Settings | File Templates.
*/
Predefined, internal, and custom file templates
RubyMine comes with a set of predefined file templates. You can use these templates as-is or modify them as necessary. You can as well create your own file templates (custom file templates).
Internal file templates are a subset of the predefined templates. These templates differ from all the other templates in that they cannot be deleted.
On the File Templates page of the Settings dialog, the names of internal templates are shown in bold. The names of the custom templates and the predefined templates that you have modified are shown in blue.
When are file templates used?
Whenever you create a new file, you can choose to create an empty file (e.g. ) or use a file template. In the latter case, the initial contents of the new file will be generated according to the template you have selected. (Basically, all the options in the New menu except File and Directory correspond to using a template.)

