Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 047af3d

Browse files
committed
Slightly simplify component placeholder selection
1 parent 684308e commit 047af3d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

html_tstring/processor.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,16 @@ def _instrument(
8383
yield s
8484
# There are always count-1 placeholders between count strings.
8585
if i < count - 1:
86+
placeholder = _placeholder(i)
87+
8688
# Special case for component callables: if the interpolation
8789
# is a callable, we need to make sure that any matching closing
8890
# tag uses the same placeholder.
8991
callable_id = callable_ids[i]
90-
if callable_id is not None:
91-
# This interpolation is a callable, so we need to make sure
92-
# that any matching closing tag uses the same placeholder.
93-
if callable_id not in callable_placeholders:
94-
callable_placeholders[callable_id] = _placeholder(i)
95-
yield callable_placeholders[callable_id]
96-
else:
97-
yield _placeholder(i)
92+
if callable_id:
93+
placeholder = callable_placeholders.setdefault(callable_id, placeholder)
94+
95+
yield placeholder
9896

9997

10098
@lru_cache()
@@ -369,3 +367,4 @@ def html(template: Template) -> Node:
369367
# where interpolations go.
370368
p_node = _instrument_and_parse(template)
371369
return _substitute_node(p_node, template.interpolations)
370+
return _substitute_node(p_node, template.interpolations)

0 commit comments

Comments
 (0)