NamedArgBlock Class
Create a named argument block.
A named arg block is used to add arguments to a function call. It needs to be combined with a function_id block to be useful. Inside a code block, if the first block is a function_id block, the first block can be a variable or value block, anything else must be a named arg block.
The value inside the NamedArgBlock can be a ValBlock or a VarBlock.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Constructor
NamedArgBlock(*, content: str, name: str | None = None, value: ValBlock | None = None, variable: VarBlock | None = None)
Parameters
| Name | Description |
|---|---|
|
str
Required
|
<xref:<xref:name ->>
The content of the named argument block, the name and value separated by an equal sign, for instance arg1=$var. |
|
str
Required
|
The name of the argument. |
|
ValBlock
Required
|
<xref:<xref:value ->>
The value of the argument. |
|
VarBlock
Required
|
<xref:<xref:variable ->>
The variable of the argument. Either the value or variable field is used. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
content
Required
|
|
|
name
Required
|
|
|
value
Required
|
|
|
variable
Required
|
|
Examples
{{ plugin.function arg1=$var }} {{ plugin.function arg1='value' }} {{ plugin.function 'value' arg2=$var }} {{ plugin.function $var arg2='value' }} {{ plugin_function arg1=$var1 arg2=$var2 arg3='value' }}
Methods
| parse_content |
Parse the content of the named argument block and extract the name and value. If the name and either value or variable is present the parsing is skipped. Otherwise, the content is parsed using a regex to extract the name and value. Those are then turned into Blocks. |
| render |
Render the named argument block. |
parse_content
Parse the content of the named argument block and extract the name and value.
If the name and either value or variable is present the parsing is skipped. Otherwise, the content is parsed using a regex to extract the name and value. Those are then turned into Blocks.
parse_content(fields: Any) -> Any
Parameters
| Name | Description |
|---|---|
|
fields
Required
|
|
Exceptions
| Type | Description |
|---|---|
|
If the content does not match the named argument syntax. |
render
Render the named argument block.
render(kernel: Kernel, arguments: KernelArguments | None = None) -> Any
Parameters
| Name | Description |
|---|---|
|
kernel
Required
|
|
|
arguments
|
Default value: None
|
Attributes
name
name: str | None
type
type: ClassVar[BlockTypes] = 7
value
value: ValBlock | None
variable
variable: VarBlock | None