The Kate Template Format
Prev
Next

The Kate Template Format

If you use files with the extension katetemplate, they will be parsed for template information, macros and a cursor position.

Template information

While reading in the file, the parser keeps lines beginning with the phrase katetemplate: and searches them for template information in the form VARIABLENAME=VALUE. The first line not starting with katetemplate: will be taken as the start of the template contents. VALUE may contain any character but equal sign (=). Legal variable names are:

Template

This is the template name, displayed in the File->New from Template menu.

Group

The group places the template in a submenu of the File->New from Template menu.

Name

This is the name that will be set for the document, and displayed in the file list and title bar. If the name contains %N that will be replaced with a number, increasing if more documents has the same name.

Highlight

The plug-in will try to set the Highlight for the new document to the value of this variable. The value should be the name, as found in the Tools->Highlighting.

Description

A short informative description of the template. This is currently used to set a Whatsthis string for the menu item, but may be used for more purposes in the future.

Author

A string identifying the author, for example in the form Name <email address>. This is currently used to set a Whatsthis string for the menu item, but may be used for more purposes in the future.

Template Macros

While parsing the template contents, macros in the form %{NAME} or ${NAME} are expanded. If you use the $ prefix, the expanded macro will be treated as a editable variable when a document is created from the template, whereas if you use % it is not, unless expanding failed.

The following macros are expanded:

time

Expands to the current time in your locale format.

date

Expands to the current date in short format.

datetime

Expands to the current date and time, formatted as a string according to your locale.

year

The current year as a four digit number.

month

The full name of the current month, according to your locale.

day

Expands to the current day of the month.

hostname

Expands to the 'hostname' of your computer.

index

Expands to 'i'.

fullname

Expands to your full name, as defined by the owner addressee in your standard KDE addressbook.

firstname

Expands to your first name, as defined in the owner addressee in your standard KDE addressbook.

lastname

Expands to your last name, as defined in the owner addressee in your standard KDE addressbook.

email

Expands to your email address, as defined by the owner address in your standard KDE addressbook.

Any macro not in the above list is treated as a editable variable no matter the prefix. If the same variable occurs multiple times in the template, they can be edited at once after creating a document from the template.

Setting the cursor position

The special macro ${cursor} will be replaced with a vertical bar and added to the end of the list of editable variables, independent on its location in the text.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team