Skip to content

Snippet actions

Snippets can be used when you have moves that you want to reuse in multiple demos. You can define a snippet in the .demo folder and reference it in your act files.

Snippets support both JSON and YAML formats. The extension automatically detects the format based on the file extension (.json, .jsonc, .yaml, or .yml).

Using a snippet

Use the snippet action to reference a snippet in your scene.

{
"action": "snippet",
"contentPath": "<relative path to the file>",
"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 snippet file in either JSON or YAML format.

The contents of the snippet file could look like this:

[
{
"action": "unselect"
},
{
"action": "insert",
"path": "{MAIN_FILE}",
"contentPath": "{CONTENT_PATH}",
"position": "{CONTENT_POSITION}"
},
{
"action": "highlight",
"path": "{MAIN_FILE}",
"position": "{HIGHLIGHT_POSITION}"
}
]

In your act file, you can reference the snippet like this:

{
"action": "snippet",
"contentPath": "./snippets/insert_and_highlight.json", // or .yaml
"args": {
"MAIN_FILE": "sample.json",
"CONTENT_PATH": "content.txt",
"CONTENT_POSITION": "3",
"HIGHLIGHT_POSITION": "4"
}
}