-
Notifications
You must be signed in to change notification settings - Fork 18
Templates
- Go to "Preferences" in the menu (it is in slightly different places depending on platform (mac, windows, linux etc.)
- In the Preferences dialog that opens, expand "Puppet", and click on "Templates".
- By default, the list of templates is empty.
- Press 'New...'
- Give the template a name, and a short description (these show up when user can select the template)
- Select a 'Context' in the drop down; the contexts are the grammar elements in the Geppetto PP parser, and you can probably guess what most of them are if you are familiar with the PP DSL language. If you want the gory details, you have to look in the grammar file itself called PP.xtext.
The template context is used when user presses CTRL+Space for context sensitive help and determines if a particular template is offered in the menu or not. If a template is selected by the user, the text is inserted into the document, and the template functionality allows the user to tab between variables that should have values, until it moves to the final position indicated in the template (and editing is done).
As an example you may enter:
Name: If-then-else
Context: IfExpression
Description: A simple if-then-else expression template
Pattern:
if ${condition} {
${then_expression}
} else {
${else_expression}
}${cursor}Since the variables then_expression and else_expression does not have any values, the user will be prompted to enter these.
More help is found in Geppetto's help system - the templating for Geppetto "pp" files is very similar to the corresponding functionality for the Java editor - search for "Editor Templates" and continue from there.