Concepts
Template Inheritance
How template inheritance and overriding actions works in Stubber
Overview
Template inheritance is a powerful feature of the Stubber Framework that allows abstracting common functionality into a base template and then overriding that functionality in a child template. This is useful for creating a base template that can be used across multiple processes and then overriding the actions in the child template to customize the behavior for each process.
Understanding template inheritance is also needed to understand how to redefine actions in a template.
Inheritance
Tree Structure
All templates are merged from the _adam template in which all the standard Stubber actions are defined.
The standard Stubber templates are merged in the following order:
Conceptually this can be represented as follows.
Inherited Functionality
When a template is merged from a parent template it inherits all the functionality of the parent template.
Conceptually this can be represented as follows.
Overriding Functionality
When a template is merged from a parent template it can override the functionality of the parent template.
This can be in the form of adding fields or tasks to an existing action for example.
Examples of functionality you might want to override are:
- Adding fields to an action
- Adding tasks to an action
- Adding a new action
- Adding a notification to an action
- Redefining a field in an action
- Redefining a task in an action
- Redefining an action description
- Redefining a notification in an action
see more below.
Top Layer Functionality
The last template in the merge chain is the standard template. It can in turn be used by other templates as a parent template if so desired.
Redefining Actions
Most of the time you will want to redefine base actions in a template.
This is done by adding the action to the template and then redefining the action in the template.
Redefining a Base Action
To redefine a base action you need to add the action to the template and then redefine the action in the template.
By Example :
To make the _update action to send an email everytime someone posts an update to the stub.
Procedure :
- Add a _update action to the template flow
- Add a notification to the _update action that sends an email
- Test the action by creating a draft stub from the template and running the _update action on the stub.