ArticleDirectory
- Can you give me a list of all the predefined variables for templates, like $ {user} and $ {date }?
Original article: Workshop.
When creating a PHP file:
<? PHP
/**
* Encoding: UTF-8
* Created on: 14:48:40 by smallchicken, microji@126.com
*/
?>
Tool-template-open the "php file" in PHP and open it in the editor,
OK. You can edit the template file.
Of course, variables such as the write time and file name must be configured separately.
<? PHP
/**
* Encoding: $ {encoding}
* Created on: $ {date }$ {time} by $ {author}, $ {email}
*/
?>
Variables must be opened in the editor in tool -- template -- User Configuration Attribute -- user. properties.
Email = microji@126.com
Author = smallchicken
$ {Date? Date? String ("yyyy-m-d ")}
$ {Time? Time? String ("H: I: s ")}
Write the variable.
The format of date and time is the same as that of PHP,
Variable names can be customized.
List of official template variables:
Http://wiki.netbeans.org/FaqTemplateVariables
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,200 8
- $ {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
- $ {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:
$ {Date? Date? String ("YYYY ")}
Actually, the configuration is pretty good.