Skip to content

Commit

Permalink
Cleaner code
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsca committed Jun 27, 2024
1 parent 5621b23 commit af5fad1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/jinjax/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
RX_PROPS_START = re.compile(r"{#-?\s*def\s+")
RX_CSS_START = re.compile(r"{#-?\s*css\s+")
RX_JS_START = re.compile(r"{#-?\s*js\s+")
RX_META_END = re.compile(r"\s*-?#}")
RX_COMMA = re.compile(r"\s*,\s*")
RX_META_HEADER = re.compile(r"^(\s*{#.*?#})+", re.DOTALL)

Expand Down Expand Up @@ -162,7 +161,7 @@ def load_metadata(self, source: str) -> None:
def_found = False

while line := header.pop():
line = line.strip() + "#}"
line = line.strip(" -")

expr = self.read_metadata_line(line, RX_PROPS_START)
if expr:
Expand All @@ -186,10 +185,7 @@ def read_metadata_line(self, source: str, rx_start: re.Pattern) -> str:
start = rx_start.match(source)
if not start:
return ""
end = RX_META_END.search(source, pos=start.end())
if not end:
raise InvalidArgument(self.name)
return source[start.end() : end.start()].strip()
return source[start.end():].strip()

def parse_args_expr(self, expr: str) -> tuple[list[str], dict[str, t.Any]]:
expr = expr.strip(" *,/")
Expand Down

0 comments on commit af5fad1

Please sign in to comment.