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

Snippet Definition Value

Table of contents

Description:

A reusable value that can be referenced in snippet templates via { ref: "key" } or { spread_ref: "key" }. Can be a string, number, boolean, parser format, parser model, array of models, or array of select options.

Appears in:
└── _snippets_definitions
    └── Snippet Definition Value
Types:

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 configuration for this argument.

An array of parser model configurations. Typically used for positional_args or named_args definitions that specify the arguments a snippet accepts. Each model defines an argument's editor key, type, default value, and whether it's optional.

An array of select option values. Commonly used for language lists in code highlighting snippets, where each option has a display name and a value. For example: [{ name: "JavaScript", value: "js" }, { name: "Python", value: "python" }].

A string value definition. Commonly used for shortcode_name, tag_name, content_key, include_name, and similar definitions that identify snippet components by name.

A numeric value definition. Use for counts, sizes, or other numeric values that can be referenced in snippet templates.

A boolean value definition. Use for flags and toggles that can be referenced in snippet templates.

An array of string values. Useful for defining lists of allowed values, delimiters, or other string collections that can be referenced in snippet templates.

Examples:
Open in a new tab