Functions
format_template
4
str
▼
Format a Kida template source string.
format_template
4
str
▼
def format_template(source: str, *, indent: int = 2, max_blank_lines: int = 1, normalize_tag_spacing: bool = True) -> str
Parameters
| Name | Type | Description |
|---|---|---|
source |
str |
Template source text. |
indent |
int |
Number of spaces per indentation level. Default:2
|
max_blank_lines |
int |
Maximum consecutive blank lines to allow. Default:1
|
normalize_tag_spacing |
bool |
If True, normalize spacing inside tags. Default:True
|
Returns
str
_normalize_tag_spacing
1
str
▼
Normalize spacing inside template tags.
_normalize_tag_spacing
1
str
▼
def _normalize_tag_spacing(source: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
source |
str |
Returns
str
_get_block_keyword
1
str | None
▼
Extract the block keyword from a line containing a block tag.
_get_block_keyword
1
str | None
▼
def _get_block_keyword(line: str) -> str | None
Parameters
| Name | Type | Description |
|---|---|---|
line |
str |
Returns
str | None
_should_dedent_before
1
bool
▼
Check if this line should be dedented (closing/continuation tags).
_should_dedent_before
1
bool
▼
def _should_dedent_before(stripped: str) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
stripped |
str |
Returns
bool
_count_indent_change
1
int
▼
Count net indent change for this line.
Returns +1 for block openers, -1 for cl…
_count_indent_change
1
int
▼
def _count_indent_change(stripped: str) -> int
Count net indent change for this line.
Returns +1 for block openers, -1 for closers that also re-indent (like else which dedents then indents).
Parameters
| Name | Type | Description |
|---|---|---|
stripped |
str |
Returns
int