summaryrefslogtreecommitdiff
path: root/htmtl/expression_parser.py
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-01-03 21:54:17 +0200
committerAsko Nõmm <asko@nmm.ee>2025-01-03 21:54:17 +0200
commite1af30fad78b2740312d631b0d4a701e30d915df (patch)
tree4e1d531f70b2818f43ff07f39a96aa4d868e09fd /htmtl/expression_parser.py
parent61c0b0d134d05c1647fa3356486d209bac87d8f6 (diff)
Implement `InnerPartial` and `OuterPartial` parsers.
Diffstat (limited to 'htmtl/expression_parser.py')
-rw-r--r--htmtl/expression_parser.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/htmtl/expression_parser.py b/htmtl/expression_parser.py
index 795bde6..fc3aa8d 100644
--- a/htmtl/expression_parser.py
+++ b/htmtl/expression_parser.py
@@ -12,11 +12,15 @@ class ExpressionParser:
def parse(self, expression: str) -> Any:
# no curly brackets means that the whole thing is an interpolation
- if expression.count("{") != expression.count("}"):
+ if expression.count("{") == 0 and expression.count("}") == 0:
parsed_interpolation = self.__parse_interpolation(expression)
return parsed_interpolation
+ # uneven curly brackets means invalid syntax
+ if expression.count("{") != expression.count("}"):
+ return expression
+
# otherwise only parts of it are
parsed_expression = ""
interp_start = None
@@ -69,7 +73,7 @@ class ExpressionParser:
return value
@staticmethod
- def __parse_args_str_to_args(args_str) -> list[str]:
+ def __parse_args_str_to_args(args_str) -> list[str | int | float | bool]:
args = []
for idx, char in enumerate(args_str):