Snippet actions
Snippets can be used when you have steps that you want to reuse in multiple demos. You can define a snippet in the .demo
folder and reference it in your demo files.
Using a snippet
Use the snippet
action to reference a snippet in your demo.
{ "action": "snippet", "contentPath": "<relative path to the file in the .demo folder>", "args": { // Define the argument name in the snippet file with curly braces {argument name} "<argument name>": "<argument value>" }}
Start by creating a snippet folder/file in the .demo
folder. For example, you can create a snippets
folder and a insert_and_highlight.json
file.
The contents of this file could look like this:
[ { "action": "unselect", "path": "{MAIN_FILE}" }, { "action": "insert", "path": "{MAIN_FILE}", "contentPath": "{CONTENT_PATH}", "position": "{CONTENT_POSITION}" }, { "action": "highlight", "path": "{MAIN_FILE}", "position": "{HIGHLIGHT_POSITION}" }]
In your demo file, you can reference the snippet like this:
{ "action": "snippet", "contentPath": "./snippets/insert_and_highlight.json", "args": { "MAIN_FILE": "sample.json", "CONTENT_PATH": "content.txt", "CONTENT_POSITION": "3", "HIGHLIGHT_POSITION": "4" }}