Skip to content

text (1)

indented

indented(text: str, indentation: str = ' ') -> bool

Check whether all lines of given text are indented.

Example

Jinja call:

{% if "    some text" is indented %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
text str

The text to check

required
indentation str

The indent each line must start with

' '
Source code in src/jinjarope/envtests.py
200
201
202
203
204
205
206
207
def is_indented(text: str, indentation: str = "    ") -> bool:
    """Check whether all lines of given text are indented.

    Args:
        text: The text to check
        indentation: The indent each line must start with
    """
    return all(i.startswith(indentation) for i in text.split("\n"))