Skip to content

Commit fdf1770

Browse files
give default parameters
1 parent 28bf247 commit fdf1770

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/reactpy/executors/asgi/pyscript.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ class ReactPyPyscriptApp(ReactPyApp):
101101
def render_index_html(self) -> None:
102102
"""Process the index.html and store the results in this class."""
103103
head_content = vdom_head_to_html(self.parent.html_head)
104-
noscript = (
105-
html_noscript_path_to_html(self.parent.html_noscript_path)
106-
if self.parent.html_noscript_path
107-
else ""
108-
)
104+
noscript = html_noscript_path_to_html(self.parent.html_noscript_path or "")
109105
pyscript_setup = pyscript_setup_html(
110106
extra_py=self.parent.extra_py,
111107
extra_js=self.parent.extra_js,

src/reactpy/executors/asgi/standalone.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ async def __call__(
238238

239239
def render_index_html(self) -> None:
240240
"""Process the index.html and store the results in this class."""
241-
noscript = (
242-
html_noscript_path_to_html(self.parent.html_noscript_path)
243-
if self.parent.html_noscript_path
244-
else ""
245-
)
241+
noscript = html_noscript_path_to_html(self.parent.html_noscript_path)
246242
self._index_html = (
247243
"<!doctype html>"
248244
f'<html lang="{self.parent.html_lang}">'

src/reactpy/executors/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ def vdom_head_to_html(head: VdomDict) -> str:
4747
raise ValueError("Head element must be constructed with `html.head`.")
4848

4949

50-
def html_noscript_path_to_html(path: str | Path) -> str:
51-
return f"<noscript>{Path(path).read_text(encoding='utf-8')}</noscript>"
50+
def html_noscript_path_to_html(path: str | Path | None = "", default_text="Please enable JavaScript to view this site.") -> str:
51+
if path:
52+
return f"<noscript>{Path(path).read_text(encoding='utf-8')}</noscript>"
53+
return f"<noscript>{default_text}</noscript>"
5254

5355

5456
def process_settings(settings: ReactPyConfig) -> None:

0 commit comments

Comments
 (0)