☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

options

Table of contents

Description:

This key defines configuration options for argument list parser configurations.

The value is an object that can contain models and format properties. These options control how multiple argument values are parsed and validated.

Appears in:
└── Snippet
    └── params
        └── *
            └── Argument List Parser Configuration
                └── options
Type:
Object Required
Properties:
formatObject#

This key defines formatting options for parsing snippet parameters.

The value is an object that can contain various options controlling how snippet parameters are parsed, including boundaries, delimiters, allowed value types, and string formatting options.

Show examplesHide examples

A common option to configure for the argument parser is the string_boundary:

Copied to clipboard
_snippets:
  video:
    snippet: <<video [[video_arg]]>>
    params:
      video_arg:
        parser: argument
        options:
          model:
            editor_key: video_id
          format:
            string_boundary:
              - '"'
              - '`'
{
  "_snippets": {
    "video": {
      "snippet": "<<video [[video_arg]]>>",
      "params": {
        "video_arg": {
          "parser": "argument",
          "options": {
            "model": {
              "editor_key": "video_id"
            },
            "format": {
              "string_boundary": [
                "\"",
                "`"
              ]
            }
          }
        }
      }
    }
  }
}

This would make our snippet match <<video "CZcNgDN81Sw">> or <<video `CZcNgDN81Sw`>> but not <<video 'CZcNgDN81Sw'>> or <<video CZcNgDN81Sw>>.

Another common requirement is specifying forbidden_tokens, especially when defining an argument with no string boundary.

Copied to clipboard
_snippets:
  video:
    snippet: <<video [[video_arg]]>>
    params:
      video_arg:
        parser: argument
        options:
          model:
            editor_key: video_id
          format:
            forbidden_tokens:
              - '>'
            string_boundary:
              - ''
{
  "_snippets": {
    "video": {
      "snippet": "<<video [[video_arg]]>>",
      "params": {
        "video_arg": {
          "parser": "argument",
          "options": {
            "model": {
              "editor_key": "video_id"
            },
            "format": {
              "forbidden_tokens": [
                ">"
              ],
              "string_boundary": [
                ""
              ]
            }
          }
        }
      }
    }
  }
}

This key defines the parsing configurations for each argument.

Matches the model options from the argument parser.

Examples:

In this example, we have configured argument list parser options with multiple models.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[param1]] [[param2]]>>
    params:
      params:
        parser: argument_list
        options:
          models:
            - editor_key: param1
            - editor_key: param2
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[param1]] [[param2]]>>",
      "params": {
        "params": {
          "parser": "argument_list",
          "options": {
            "models": [
              {
                "editor_key": "param1"
              },
              {
                "editor_key": "param2"
              }
            ]
          }
        }
      }
    }
  }
}
Open in a new tab