diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-01-04 22:24:42 +0200 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2025-01-04 22:24:42 +0200 |
| commit | 51904366dd5c46c8d8d37e333b538b7574360ff5 (patch) | |
| tree | 62ad511ca930c0b73ab7571c5c59c984044c6ed1 /htmtl/parsers/when_not.py | |
| parent | 4b7492306621d8a7555bd01fc7d8cc3b910ae17b (diff) | |
Implement `When` and `WhenNot` parsers.
Diffstat (limited to 'htmtl/parsers/when_not.py')
| -rw-r--r-- | htmtl/parsers/when_not.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/htmtl/parsers/when_not.py b/htmtl/parsers/when_not.py new file mode 100644 index 0000000..68e3d09 --- /dev/null +++ b/htmtl/parsers/when_not.py @@ -0,0 +1,14 @@ +from typing import Optional +from dompa.nodes import Node +from ..parser import Parser + + +class WhenNot(Parser): + def traverse(self, node: Node) -> Optional[Node]: + if "when-not" in node.attributes: + if self.expression(node.attributes["when-not"]): + return None + + node.attributes.pop("when-not") + + return node
\ No newline at end of file |
