Skip to content

Commit 0fb7678

Browse files
committed
simplify render method for bare
1 parent e7cc0ec commit 0fb7678

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

reflex/components/base/bare.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import json
65
from collections.abc import Iterator, Sequence
76
from typing import Any
87

@@ -170,11 +169,14 @@ def _get_all_refs(self) -> set[str]:
170169
return refs
171170

172171
def _render(self) -> Tag:
173-
if isinstance(self.contents, Var):
174-
if isinstance(self.contents, (BooleanVar, ObjectVar)):
175-
return Tagless(contents=f"{self.contents.to_string()!s}")
176-
return Tagless(contents=f"{self.contents!s}")
177-
return Tagless(contents=f'"{json.dumps(self.contents)}"')
172+
contents = (
173+
Var.create(self.contents)
174+
if not isinstance(self.contents, Var)
175+
else self.contents
176+
)
177+
if isinstance(contents, (BooleanVar, ObjectVar)):
178+
return Tagless(contents=f"{contents.to_string()!s}")
179+
return Tagless(contents=f"{contents!s}")
178180

179181
def _add_style_recursive(
180182
self, style: ComponentStyle, theme: Component | None = None

0 commit comments

Comments
 (0)