options

On this page

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.

Appears in: Repeating Parser Configuration options.

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.

Appears in: Repeating Parser Configuration options.

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

Appears in: Repeating Parser Configuration options.

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. Setting this key to block outputs values with leading and trailing newlines, and inline outputs values on a single line with newlines inserted as \n. If unspecified, inline is used when the value is a single line, otherwise block formatting is used.

Appears in: Repeating Parser Configuration options.

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.

Appears in: Repeating Parser Configuration options.

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.

Appears in: Content Parser Configuration options, Key Value List Parser Configuration options, Repeating Parser Configuration options, Wrapper Parser Configuration options.

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