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

Key Value List Parser Configuration

Table of contents

Description:

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.

Appears in:
└── Snippet
    └── params
        └── *
            └── Key Value List Parser Configuration
Type:
Object
Properties:
optionsObject#

This key defines configuration options for key-value list parser configurations.

The value is an object that can contain models, format, and style properties. These options control how multiple key-value pairs are parsed and validated.

Show examplesHide examples

In this example, we have configured key-value list parser options with models.

Copied to clipboard
_snippets:
  example:
    snippet: <<example key1=value1 key2=value2>>
    params:
      params:
        parser: key_values
        options:
          models:
            key1:
              editor_key: value1_input
            key2:
              editor_key: value2_input
{
  "_snippets": {
    "example": {
      "snippet": "<<example key1=value1 key2=value2>>",
      "params": {
        "params": {
          "parser": "key_values",
          "options": {
            "models": {
              "key1": {
                "editor_key": "value1_input"
              },
              "key2": {
                "editor_key": "value2_input"
              }
            }
          }
        }
      }
    }
  }
}
parser"key_values" Required#

This key defines the parser type for key-value list parser configurations.

The value must be key_values. This specifies that the parameter uses the key-value list parser, which parses multiple key-value pairs.

Show examplesHide examples

In this example, we have configured a key-value list parser for a snippet parameter.

Copied to clipboard
_snippets:
  example:
    snippet: <<example key1=value1 key2=value2>>
    params:
      params:
        parser: key_values
        options:
          models:
            key1:
              editor_key: value1_input
            key2:
              editor_key: value2_input
{
  "_snippets": {
    "example": {
      "snippet": "<<example key1=value1 key2=value2>>",
      "params": {
        "params": {
          "parser": "key_values",
          "options": {
            "models": {
              "key1": {
                "editor_key": "value1_input"
              },
              "key2": {
                "editor_key": "value2_input"
              }
            }
          }
        }
      }
    }
  }
}
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}/>
      └───────────────────────────┘
Open in a new tab