Skip to content

Commit 027d2a1

Browse files
committed
add pyscript tag to the user API
1 parent 260ca3d commit 027d2a1

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/reactpy_django/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
import nest_asyncio
44

5-
from reactpy_django import checks, components, decorators, hooks, router, types, utils
5+
from reactpy_django import (
6+
checks,
7+
components,
8+
decorators,
9+
hooks,
10+
html,
11+
router,
12+
types,
13+
utils,
14+
)
615
from reactpy_django.websocket.paths import (
716
REACTPY_WEBSOCKET_PATH,
817
REACTPY_WEBSOCKET_ROUTE,
@@ -12,6 +21,7 @@
1221
__all__ = [
1322
"REACTPY_WEBSOCKET_PATH",
1423
"REACTPY_WEBSOCKET_ROUTE",
24+
"html",
1525
"hooks",
1626
"components",
1727
"decorators",

src/reactpy_django/components.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
from django.contrib.staticfiles.finders import find
1212
from django.core.cache import caches
1313
from django.http import HttpRequest
14-
from django.templatetags.static import static
1514
from django.urls import reverse
1615
from django.views import View
1716
from reactpy import component, hooks, html, utils
1817
from reactpy.types import ComponentType, Key, VdomDict
1918

2019
from reactpy_django.exceptions import ViewNotRegisteredError
20+
from reactpy_django.html import pyscript
2121
from reactpy_django.utils import (
22-
PYSCRIPT_TAG,
2322
extend_pyscript_config,
2423
generate_obj_name,
2524
import_module,
@@ -337,7 +336,7 @@ def _python_to_pyscript(
337336

338337
return html.div(
339338
html.div((extra_props or {}) | {"id": f"pyscript-{uuid}"}, initial),
340-
PYSCRIPT_TAG(
339+
pyscript(
341340
{"async": "", "config": orjson.dumps(new_config).decode()},
342341
executor,
343342
),

src/reactpy_django/html.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from reactpy.core.vdom import make_vdom_constructor
2+
3+
pyscript = make_vdom_constructor("py-script")

src/reactpy_django/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from reactpy.backend.hooks import ConnectionContext
3131
from reactpy.backend.types import Connection, Location
3232
from reactpy.core.layout import Layout
33-
from reactpy.core.vdom import make_vdom_constructor
3433
from reactpy.types import ComponentConstructor
3534

3635
from reactpy_django.exceptions import (
@@ -58,7 +57,6 @@
5857
PYSCRIPT_COMPONENT_TEMPLATE = (
5958
Path(__file__).parent / "pyscript" / "component_template.py"
6059
).read_text(encoding="utf-8")
61-
PYSCRIPT_TAG = make_vdom_constructor("py-script")
6260
PYSCRIPT_DEFAULT_CONFIG = {
6361
"packages": [
6462
f"reactpy=={reactpy.__version__}",

0 commit comments

Comments
 (0)