RubyMine 2017.3 Help

File Template Variables

A file template can contain template variables. When a template is applied, the variables are replaced with their values.

A file template variable is a string that starts with a dollar sign which is followed by the variable name. The variable name may be enclosed in curly braces. For example: $MyVariable or ${MyVariable}.

Predefined template variables

RubyMine comes with a set of predefined template variables.

The available predefined file template variables are:

  • ${PROJECT_NAME} - the name of the current project.
  • ${NAME} - the name of the new file which you specify in the New File dialog box during the file creation.
  • ${USER} - the login name of the current user.
  • ${DATE} - the current system date.
  • ${YEAR} - the current year.
  • ${MONTH} - the current month.
  • ${DAY} - the current day of the month.
  • ${TIME} - the current system time.
  • ${HOUR} - the current hour.
  • ${MINUTE} - the current minute.
  • ${PRODUCT_NAME} - the name of the IDE in which the file will be created.
  • ${MONTH_NAME_SHORT} - the first 3 letters of the month name. Example: Jan, Feb, etc.
  • ${MONTH_NAME_FULL} - full name of a month. Example: January, February, etc.

Custom template variables

In addition to the predefined template variables, it is possible to specify custom variables. If necessary, you can define the values of custom variables right in a template using the #set VTL directive.

For example, if you want to use your full name instead of your login name defined through the pre-defined variable ${USER}, write the following construct:

#set( $MyName = "John Smith" )

If the value of a variable is not defined in the template, RubyMine will ask you to specify it when the template is applied.

You can prevent treating dollar characters ($) in template variables as prefixes. If you need a dollar character ($ inserted as is, use the ${DS} file template variable instead. When the template is applied, this variable evaluates to a plain dollar character ($).

Last modified: 4 April 2018

See Also