Check if the object passed is undefined. This does nothing more than performing an instance check against :class:`Undefined` but looks nicer. This can be used for custom filters or tests that want to react to undefined variables. For example a custom default filter can look like th
(obj: t.Any)
| 102 | |
| 103 | |
| 104 | def is_undefined(obj: t.Any) -> bool: |
| 105 | """Check if the object passed is undefined. This does nothing more than |
| 106 | performing an instance check against :class:`Undefined` but looks nicer. |
| 107 | This can be used for custom filters or tests that want to react to |
| 108 | undefined variables. For example a custom default filter can look like |
| 109 | this:: |
| 110 | |
| 111 | def default(var, default=''): |
| 112 | if is_undefined(var): |
| 113 | return default |
| 114 | return var |
| 115 | """ |
| 116 | from .runtime import Undefined |
| 117 | |
| 118 | return isinstance(obj, Undefined) |
| 119 | |
| 120 | |
| 121 | def consume(iterable: t.Iterable[t.Any]) -> None: |
no outgoing calls