only render once
This commit is contained in:
parent
67b8eb9b15
commit
c7a234b94d
@ -2365,24 +2365,15 @@ def empty_component() -> Component:
|
||||
return Bare.create("")
|
||||
|
||||
|
||||
@dataclasses.dataclass(
|
||||
eq=False,
|
||||
frozen=True,
|
||||
)
|
||||
class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
|
||||
"""A Var that represents a Component."""
|
||||
def render_dict_to_var(tag: dict) -> Var:
|
||||
"""Convert a render dict to a Var.
|
||||
|
||||
_var_value: Component = dataclasses.field(default_factory=empty_component)
|
||||
|
||||
@cached_property_no_lock
|
||||
def _cached_var_name(self) -> str:
|
||||
"""Get the name of the var.
|
||||
Args:
|
||||
tag: The render dict.
|
||||
|
||||
Returns:
|
||||
The name of the var.
|
||||
The Var.
|
||||
"""
|
||||
tag = self._var_value.render()
|
||||
|
||||
props = {}
|
||||
|
||||
special_props = []
|
||||
@ -2403,19 +2394,36 @@ class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
|
||||
|
||||
contents = tag["contents"][1:-1] if tag["contents"] else None
|
||||
|
||||
tag_name = Var(tag.get("name", None) or "Fragment")
|
||||
tag_name = Var(tag.get("name") or "Fragment")
|
||||
|
||||
return str(
|
||||
FunctionStringVar.create(
|
||||
return FunctionStringVar.create(
|
||||
"jsx",
|
||||
).call(
|
||||
tag_name,
|
||||
props,
|
||||
*([Var(contents)] if contents is not None else []),
|
||||
*[Var.create(child) for child in self._var_value.children],
|
||||
)
|
||||
*[render_dict_to_var(child) for child in tag["children"]],
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass(
|
||||
eq=False,
|
||||
frozen=True,
|
||||
)
|
||||
class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
|
||||
"""A Var that represents a Component."""
|
||||
|
||||
_var_value: Component = dataclasses.field(default_factory=empty_component)
|
||||
|
||||
@cached_property_no_lock
|
||||
def _cached_var_name(self) -> str:
|
||||
"""Get the name of the var.
|
||||
|
||||
Returns:
|
||||
The name of the var.
|
||||
"""
|
||||
return str(render_dict_to_var(self._var_value.render()))
|
||||
|
||||
@cached_property_no_lock
|
||||
def _cached_get_all_var_data(self) -> VarData | None:
|
||||
"""Get the VarData for the var.
|
||||
|
Loading…
Reference in New Issue
Block a user