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

optional

Table of contents

Description:

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

Setting this key to true will make the content parameter optional, allowing snippets to match even when the content is missing.

By default, this key is false (i.e., content is required).

Appears in:
└── Snippet
    └── params
        └── *
            └── Content Parser Configuration
                └── options
                    └── optional
Type:
boolean
Examples:

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

Copied to clipboard
_snippets:
  highlight:
    snippet: <<highlight>> [[content]] <</highlight>>
    params:
      content:
        parser: content
        options:
          editor_key: highlighted_text
          optional: true
{
  "_snippets": {
    "highlight": {
      "snippet": "<<highlight>> [[content]] <</highlight>>",
      "params": {
        "content": {
          "parser": "content",
          "options": {
            "editor_key": "highlighted_text",
            "optional": true
          }
        }
      }
    }
  }
}
Open in a new tab