ValBlock Class
Create a value block.
A value block is used to represent a value in a template. It can be used to represent any characters. It needs to start and end with the same quote character, can be both single or double quotes, as long as they are not mixed.
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
ValBlock(*, content: str, value: str | None = '', quote: str | None = "'")
Parameters
| Name | Description |
|---|---|
|
str
Required
|
<xref:<xref:quote ->>
The content of the value block. |
|
str
Required
|
The value of the block. |
|
str
Required
|
The quote used to wrap the value. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
content
Required
|
|
|
value
Required
|
|
|
quote
|
Default value: '
|
Examples
'value' "value" 'value with "quotes"' "value with 'quotes'"
Methods
| parse_content |
Parse the content and extract the value and quote. The parsing is based on a regex that returns the value and quote. if the 'value' is already present then the parsing is skipped. |
| render |
Render the value block. |
parse_content
Parse the content and extract the value and quote.
The parsing is based on a regex that returns the value and quote. if the 'value' is already present then the parsing is skipped.
parse_content(fields: Any) -> Any
Parameters
| Name | Description |
|---|---|
|
fields
Required
|
|
render
Render the value block.
render(*_: Kernel | KernelArguments | None) -> str
Attributes
quote
quote: str | None
type
type: ClassVar[BlockTypes] = 5
value
value: str | None