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).

Demo Time includes a Snippet Gallery so you can browse and download community snippets directly from VS Code.

  • Open it from the Demo Time resources section via Snippet Gallery.
  • Browse snippets by name, tags, description, author, version, and available fields.
  • Download snippets with one click into your workspace under .demo/snippets/....
  • Already downloaded snippets are shown with a Downloaded status and can be Re-downloaded when needed.

Once a snippet is downloaded, use it exactly like any local snippet via the snippet action and contentPath.

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"
}
}