This key defines the parsing configuration for this argument.
Appears in
├── Snippet
│ └── params
│ └── *
│ ├── Argument List Parser Configuration
│ │ └── options
│ │ └── models
│ │ └── Snippet Model
│ ├── Argument Parser Configuration
│ │ └── options
│ │ └── Snippet Model
│ └── Key Value List Parser Configuration
│ └── options
│ └── models
│ └── Snippet Model
└── Snippet Definition Value
├── Snippet Model
└── Parser Model Array
└── Snippet ModelType
Object
Properties
This key defines a list of valid values for the parser.
If specified, values not in the provided list will cause this snippet to be skipped,
and a different snippet will be matched if possible.
A user entering a different value while editing this snippet will cause it to error, so this option is
best paired with a select input configured on the editor_key.
Appears in: Snippet Model.
Show examplesHide examples
parser: argument
options:
model:
editor_key: video_id
allowed_values:
- riXoAr6gO-E
- CZcNgDN81Sw
- 0iwNjcFIHNM{
"parser": "argument",
"options": {
"model": {
"editor_key": "video_id",
"allowed_values": [
"riXoAr6gO-E",
"CZcNgDN81Sw",
"0iwNjcFIHNM"
]
}
}
}Example usage:
## My blog post
<<video "CZcNgDN81Sw">>
<<video "riXoAr6gO-E">>
<<video "RuvMHkfOpvg">>
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.These IDs match a value in allowed_values, thus will be shown as a video snippet
This ID is not present in allowed_values and will not parse as a video snippet.
It may still parse as another snippet, or will remain as plain text.
default — unknown#This key defines the key that a user in CloudCannon will see when editing this value.
This key will also be used if you want to specify any input configuration using _inputs.
If no source_key is set, this key will also be assumed to be the source key.
Appears in: Snippet Model.
Show examplesHide examples
parser: key_values
options:
models:
- editor_key: href
- editor_key: class
- editor_key: target{
"parser": "key_values",
"options": {
"models": [
{
"editor_key": "href"
},
{
"editor_key": "class"
},
{
"editor_key": "target"
}
]
}
}Key/value models can be specified in any order, so do not have to match the order of they keys in the source code.
Example usage:
## My blog post
<a href="#link" target="_blank" class="my_link"> ... </a>
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.When edited in CloudCannon, this will edit as the data model:
href: '#link'
target: _blank
class: my_link{
"href": "#link",
"target": "_blank",
"class": "my_link"
}This key toggles whether any value in this argument will alias to true, and an empty value will alias to false.
Setting this key to true will cause any value in this argument to alias to true, and an empty value to alias to false.
By default, this key is false (i.e., values are not aliased to boolean).
Defaults to: false
Appears in: Snippet Model.
Show examplesHide examples
In this example, we have configured implied boolean so any value in this argument will alias to true, and an empty value will alias to false.
parser: argument
options:
model:
editor_key: has_video_id
implied_boolean: true{
"parser": "argument",
"options": {
"model": {
"editor_key": "has_video_id",
"implied_boolean": true
}
}
}This key toggles whether a value must exist for this parser.
Setting this key to true will make the value optional for this parser. Useful for long sets of key-value pairs that are not all required.
By default, this key is false (i.e., a value must exist for this parser).
Defaults to: false
Appears in: Snippet Model.
Show examplesHide examples
parser: key_values
options:
models:
- editor_key: href
- editor_key: target
optional: true
- editor_key: class
optional: true{
"parser": "key_values",
"options": {
"models": [
{
"editor_key": "href"
},
{
"editor_key": "target",
"optional": true
},
{
"editor_key": "class",
"optional": true
}
]
}
}Example usage:
## My blog post
<a href="#link" target="_blank" class="my_link"> ... </a>
<a href="#link" target="_blank"> ... </a>
<a href="#link"> ... </a>
<a target="_blank"> ... </a>
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.All of these anchor tags will parse correctly, as they are missing either target or class
keys from the arguments, and both are marked as optional.
This anchor tag will not be parsed, as the href key is absent and is not marked as optional.
This key toggles whether this key-value pair should be omitted altogether if the value is empty.
Setting this key to true will omit the key-value pair if the value is empty. Requires that this key is also set as optional, as otherwise the snippet would not re-parse.
By default, this key is false (i.e., empty key-value pairs are not omitted).
Defaults to: false
Appears in: Snippet Model.
Show examplesHide examples
parser: key_values
options:
models:
- editor_key: href
- editor_key: target
- editor_key: class
optional: true
remove_empty: true{
"parser": "key_values",
"options": {
"models": [
{
"editor_key": "href"
},
{
"editor_key": "target"
},
{
"editor_key": "class",
"optional": true,
"remove_empty": true
}
]
}
}Example usage:
## My blog post
<a href="#link" target="_blank" class=""> ... </a>
<a href="#link" target="_blank"> ... </a>
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.With remove_empty: true both of these anchor tags will be output as <a href="#link" target="_blank"> ... </a>
as the class key contains no value.
If remove_empty: false was set, this snippet would be output as <a href="#link" target="_blank" class=""> ... </a>.
The empty class key would be written even if it did not originally appear in the parsed source.
This key defines the key that the parser should look for in the source text.
This only needs to be set if it differs from the editor_key.
Appears in: Snippet Model.
Show examplesHide examples
parser: key_values
options:
models:
- source_key: href
editor_key: link
- source_key: target
editor_key: link_target
- source_key: class
editor_key: classnames{
"parser": "key_values",
"options": {
"models": [
{
"source_key": "href",
"editor_key": "link"
},
{
"source_key": "target",
"editor_key": "link_target"
},
{
"source_key": "class",
"editor_key": "classnames"
}
]
}
}Key/value models can be specified in any order, so do not have to match the order of they keys in the source code.
Example usage:
## My blog post
<a href="#link" target="_blank" class="my_link"> ... </a>
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.When edited in CloudCannon, this will edit as the data model:
link: '#link'
link_target: _blank
classnames: my_link{
"link": "#link",
"link_target": "_blank",
"classnames": "my_link"
}This key defines the data type for snippet parameter parsing.
The value can be array, object, string, boolean, or number. This specifies the expected data type when parsing snippet parameters.
Allowed values: array object string boolean number
Appears in: Snippet Model.
Show examplesHide examples
In this example, we have configured a snippet model to expect a string type.
_snippets:
example:
snippet: <<example [[param]]>>
params:
param:
parser: argument
options:
model:
type: string{
"_snippets": {
"example": {
"snippet": "<<example [[param]]>>",
"params": {
"param": {
"parser": "argument",
"options": {
"model": {
"type": "string"
}
}
}
}
}
}
}