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

options

Table of contents

Description:

This key defines configuration options for repeating parser configurations.

The value is an object that can contain snippet, editor_key, output_delimiter, default_length, style, and optional properties. These options control which snippet configuration is repeated and how repetitions are handled.

Appears in:
└── Snippet
    └── params
        └── *
            └── Repeating Parser Configuration
                └── options
Type:
Object Required
Properties:

This key defines how many repetitions should be created in the initial data when initializing a new Snippet.

This key defines the editor key for repeating parser configurations.

The value is a string that specifies the key name of an input to use for editing repeating snippet instances.

Show examplesHide examples

In this example, we have configured an editor key for repeating parser.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[repeating_content]]>>
    params:
      repeating_content:
        parser: repeating
        options:
          snippet: content
          editor_key: content_items
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[repeating_content]]>>",
      "params": {
        "repeating_content": {
          "parser": "repeating",
          "options": {
            "snippet": "content",
            "editor_key": "content_items"
          }
        }
      }
    }
  }
}
optionalboolean#

This key toggles whether CloudCannon will treat repeating snippets as optional when parsing snippet parameters.

Setting this key to true will make the repeating snippet instances optional, allowing snippets to match even when no instances are present.

By default, this key is false (i.e., at least one instance is required).

Show examplesHide examples

In this example, we have configured repeating parser to treat instances as optional.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[repeating_content]]>>
    params:
      repeating_content:
        parser: repeating
        options:
          snippet: content
          optional: true
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[repeating_content]]>>",
      "params": {
        "repeating_content": {
          "parser": "repeating",
          "options": {
            "snippet": "content",
            "optional": true
          }
        }
      }
    }
  }
}

This key defines how to format the output for parsers such as the content and repeating parsers.

Valid values are either inline or block.

When set to block, values will always be output with leading and trailing newlines.

When set to inline, values will always be output on a single line, with newlines inserted as \n.

If unspecified, inline will be chosen when the value is a single line, otherwise block formatting will be used.

snippetstring Required#

This key defines the snippet configuration to repeat for repeating parser configurations.

The value is a string that specifies the key name of another snippet configuration defined in _snippets. This snippet configuration will be repeated multiple times.

Show examplesHide examples

In this example, we have configured a snippet reference for repeating parser.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[repeating_content]]>>
    params:
      repeating_content:
        parser: repeating
        options:
          snippet: content
  content:
    snippet: <<content [[text]]>>
    params:
      text:
        parser: content
        options:
          editor_key: content_text
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[repeating_content]]>>",
      "params": {
        "repeating_content": {
          "parser": "repeating",
          "options": {
            "snippet": "content"
          }
        }
      }
    },
    "content": {
      "snippet": "<<content [[text]]>>",
      "params": {
        "text": {
          "parser": "content",
          "options": {
            "editor_key": "content_text"
          }
        }
      }
    }
  }
}
styleObject#

This key defines styling options for snippet output formatting.

The value is an object that can contain output, inline, and block properties. These options control how snippet content is parsed and formatted to produce cleaner source code.

Show examplesHide examples

In this example, we have configured snippet style with inline and block formatting options.

Copied to clipboard
_snippets:
  highlight:
    snippet: <<highlight>> [[content]] <</highlight>>
    params:
      content:
        parser: content
        options:
          style:
            inline:
              leading: ' '
              trailing: ' '
            block:
              leading: \n
              trailing: \n
              indent: '  '
{
  "_snippets": {
    "highlight": {
      "snippet": "<<highlight>> [[content]] <</highlight>>",
      "params": {
        "content": {
          "parser": "content",
          "options": {
            "style": {
              "inline": {
                "leading": " ",
                "trailing": " "
              },
              "block": {
                "leading": "\\n",
                "trailing": "\\n",
                "indent": "  "
              }
            }
          }
        }
      }
    }
  }
}
Examples:

In this example, we have configured repeating parser options with a snippet reference.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[repeating_content]]>>
    params:
      repeating_content:
        parser: repeating
        options:
          snippet: content
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[repeating_content]]>>",
      "params": {
        "repeating_content": {
          "parser": "repeating",
          "options": {
            "snippet": "content"
          }
        }
      }
    }
  }
}
Open in a new tab