Code templates
Templates can be used to define source code patterns that are often repeated. They are inserted by content assist (CTRL+SPACE).
There are some templates already defined in RED. User custom templates can be also defined in
Window -> Preferences -> Robot Framework -> Editor -> Templates
.
Template context description
Contexts mean places in document where given template makes sense and can be inserted.
There are following contexts defined in RED:
- Keyword call - makes sense when cursor is placed in places where Robot keyword can be executed
- New keyword - makes sense only when the cursor is placed in the line beginning inside *** Keywords *** section
- New section - makes sense only when the cursor is placed in the line beginning inside any section
- New task - makes sense only when the cursor is placed in the line beginning inside *** Tasks *** section
- New test - makes sense only when the cursor is placed in the line beginning inside *** Test Cases *** section
Automatic proposal insertion
When there is only one proposal matching user content and automatic insertion is enabled, code assistant will choose and insert it automatically.
To enable such behavior new preference "Insert single proposals automatically" was added to
Window -> Preferences -> Robot Framework -> Editor -> Content Assist
.
This preference has to be enabled first, then "Automatically insert" option from templates will work as described.
Variables in templates
Template patterns can contain custom user variables. When template is inserted user can define values for such variables.
There are also several Eclipse predefined variables, which can be inserted with "Insert variables" button or by content assist in pattern editor. Such variables are resolved to concrete values when the template is inserted.
Following example contains predefined Eclipse variable for dollar sign escape together with two user variables:
$${${name}}= Set Variable ${value}