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

params.*

Table of contents

Description:

This key represents an individual snippet parameter configuration in the params object.

The value is an object that defines a parser configuration for a snippet parameter. Each parameter can use different parser types (argument, content, literal, etc.) with their specific options.

Appears in:
└── Snippet
    └── params
        └── *
Types:

This key defines a parser configuration that parses a list of distinct positional arguments based on their position.

Show examplesHide examples

In this example, we have configured an argument list parser to parse distinct positional arguments based on their position.

Markdown
Copied to clipboard
{{<figure "image.png" "My image title">}}
          └──────────────────────────┘

This key defines a parser configuration that parses a single argument, optionally delimited by characters.

Useful for matching a single positional argument.

The argument parser is also used to parse a list of repeating arguments.

Show examplesHide examples

In this example, we have configured an argument parser to parse a single positional argument.

Markdown
Copied to clipboard
{{<figure image.png>}}
          └───────┘

In this example, we have configured an argument parser to parse a list of repeating arguments.

Markdown
Copied to clipboard
{{<images image1.png image2.png image3.png>}}
          └──────────────────────────────┘

This key defines a parser configuration that parses rich multiline content, such as the content between paired tags. Can be configured to parse nested snippets within.

Show examplesHide examples

In this example, we have configured a content parser to parse rich multiline content between paired tags.

Liquid
Copied to clipboard
{% highlight "js" %} let a = b; {% endhighlight %}
                    └──────────┘

This key defines a parser configuration that parses repeating pairs of keys and values.

Useful for most SSG snippets that take properties.

Can be configured to handle most syntax forms of key value pairs.

Show examplesHide examples

In this example, we have configured a key-value list parser to parse repeating pairs of keys and values in Liquid syntax.

Liquid
Copied to clipboard
{% include "image.html" image: "tree.png" alt: "Image of a tree" %}
                        └──────────────────────────────────────┘

In this example, we have configured a key-value list parser to parse repeating pairs of keys and values in Markdown syntax.

Markdown
Copied to clipboard
<Link href="/about/" new_tab={true}/>
      └───────────────────────────┘

This key defines a parser configuration that parses an exact literal value. Mainly useful when configuring a snippet template.

This key toggles whether matching zero times is a valid state for this parser.

Setting this key to true will allow matching zero times as a valid state. If false, this parser requires at least one matching value. Setting this to true is preferred to wrapping the repeating parser inside an optional parser.

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

This key defines a parser configuration that parses a repeating set of exact literal values.

This key defines a higher-order parser configuration that wraps a snippet string and allows it to repeat.

This key defines a wrapper parser configuration for wrapping another snippet configuration.

The value is an object that contains a parser property set to wrapper and an options object with snippet and optional remove_empty properties. The wrapper parser wraps another snippet configuration, allowing it to be used within a different snippet context.

Show examplesHide examples

In this example, we have configured a wrapper parser to wrap a content snippet.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[wrapped_content]]>>
    params:
      wrapped_content:
        parser: wrapper
        options:
          snippet: content
  content:
    snippet: <<content [[text]]>>
    params:
      text:
        parser: content
        options:
          editor_key: content_text
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[wrapped_content]]>>",
      "params": {
        "wrapped_content": {
          "parser": "wrapper",
          "options": {
            "snippet": "content"
          }
        }
      }
    },
    "content": {
      "snippet": "<<content [[text]]>>",
      "params": {
        "text": {
          "parser": "content",
          "options": {
            "editor_key": "content_text"
          }
        }
      }
    }
  }
}
Examples:

In this example, we have configured a snippet parameter using an argument parser.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[param]]>>
    params:
      param:
        parser: argument
        options:
          model:
            editor_key: example_id
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[param]]>>",
      "params": {
        "param": {
          "parser": "argument",
          "options": {
            "model": {
              "editor_key": "example_id"
            }
          }
        }
      }
    }
  }
}
Open in a new tab