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).
Appears in
└── Snippet Model
└── optionalType
boolean
Default value
false
Examples
Copied to clipboard
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:
Markdown
Copied to clipboard
## 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.