FaqTemplateVariables
Revision as of 02:16, 15 December 2011 by Dawmail333 (Talk | contribs)
Can you give me a list of all the predefined variables for templates, like ${user} and ${date}?
- ${date} inserts the current date, in this format: Feb 16, 2008
- ${encoding} inserts the default encoding, such as: UTF-8
- ${name} inserts the name of the file.
- ${nameAndExt} inserts the name of the file, together with its extension.
- ${package} inserts the name of the package where the file is created.
- ${time} inserts the current time, in this format: 7:37:58 PM
- ${user} inserts the user name.
- ${project.license} based on the value (e.g., 'CDDL'), the license header is found and is inserted into the template.
- ${project.name} inserts the project name
- ${project.displayName} inserts the project displayname
For more details, go here.
How do I override those predefined variables?
- Go to Tools | Templates.
- Scroll to the end of the Template Manager and expand 'User Configuration Properties'.
- Select 'User.properties' and click 'Open in Editor'.
- Now you can add the above and set your own value, for example:
user=DonaldDuck@disney.com
Now, whenever you have ${user} in a file template, you will find the above value generated into the file that you create using that template.
Note: The ${date} variable is of type String, not type Date. You have to cast it to a Date type then do the format. For example, to show the year only, do this:
<#setting locale="en_AU"> <- Needed if you're in a locale that stores dates differently (e.g. dd/mm/yyyy)
...
${date?date?string("yyyy")}
Also, follow this issue, which aims to make the above more discoverable: issue 127490.
Applies to: NetBeans 6.x
Platforms: All
