Rule and Action Templates
Templates allow fragments of rules and actions to be created and stored, and reused by
rules, actions, and other templates.
If a modification is
made, the change is picked up by all items referencing the template.
Note: You cannot delete a template when it is referenced.
Rule and action templates can be referenced inside other templates so that trees of rule templates
can be created with a rule or action at the root.
Note: If a template tree is too deep, you may experience performance issues.
The output from the template can be a value, a condition, or a relation.
For example, a template can be used to define the relationship between road elements
that make up a roundabout. The parameters are the objects that define the roundabout,
and the output is a geometry value. This template can then be used in all rules that
need to access roundabout geometries.
Creating Templates
Rule and action templates are created with objects as parameters. The object is defined in an
input parameter to the template. A template can have zero to many parameters.
Parameters can be added, removed, and changed even when the template is referenced.
Create a Rule Template
-
Navigate to the Rules page.
-
In the Navigation Pane, select New > Rule Template.
A new rule template opens.
-
On the General tab in the Name field, enter the name of the rule template.
-
On the Rule Condition tab, select the Rule template node.
-
On the right-hand pane, click Add parameter.
-
To rename the class in the template to match the class in this rule, select the Parameter [n] checkbox.
-
In the Class list, select the class for the parameter.
-
In the Name field, enter a name for the parameter.
Click Add parameter.
-
Repeat steps 5 to 8 until you have added all your parameters.
-
Set up the conditions for the rule fragment.
-
Click Save.
The rule template is saved in your selected folder.
Create an Action Template
-
Navigate to the Actions page.
-
In the Navigation Pane, select New > Action Template.
A new action template opens.
-
On the General tab, type the name for the action template in the Name field.
-
On the Action Definition tab, select the Action template node.
-
On the right-hand pane, click Add parameter.
-
Select Parameter [n] to rename the class in the template to match the class in the action.
-
In the Class field, enter the class for your parameter.
-
In the Name field, enter the name for your parameter.
-
Repeat steps 5 to 8 until you have added all your parameters.
-
Set up the conditions for the action fragment.
-
Click Save.
The action template is saved in your selected folder.
Using a Template
Templates can be used within rules, actions or other templates.
Once inserted into a rule or action, a template fragment is tailored to use the classes required.
Note: To pass parameters correctly, each parameter's class or name must be used in the rule or
action before the template is inserted.
Use a Template within a Rule
- Navigate to the required node in the rule.
- Click and select Rule Template.
- Select a rule template and click OK. The rule template is inserted into the rule.
Use a Template within an Action
-
Navigate to the required node in the action.
-
Click and Action Template.
-
Select the action template from the list and click OK. The action template is inserted into the action.