Skip to content

Commit b22ce44

Browse files
committed
self-review
1 parent 95aa90c commit b22ce44

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ Using the following categories, list your changes in this order:
3636

3737
### Added
3838

39-
- Client-side Python components can now be rendered via the new `pyscript_component` template tag
39+
- Client-side Python components can now be rendered via the new `{% pyscript_component %}` template tag
40+
- PyScript's can be made accessible for an existing page using the `{% pyscript_setup %}` template tag
41+
- This tag can also be used to load additional dependencies, or change the default PyScript configuration.
4042
- Client-side components can be embedded into existing server-side components via `reactpy_django.components.pyscript_component`.
4143
- You can now write Python code that runs within client browser via the `reactpy_django.html.pyscript` element. This is a viable substitution for most JavaScript code.
4244

docs/src/reference/router.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ URL router that enables the ability to conditionally render other components bas
2020

2121
!!! warning "Pitfall"
2222

23-
All pages where this component exists must have the same, or more permissive exposure within Django's [URL patterns](https://docs.djangoproject.com/en/5.0/topics/http/urls/#example). You can think of this component as a secondary, client-side router. Django still handles the primary server-side routes.
23+
All pages where `django_router` is used must have the same, or more permissive URL exposure within Django's [URL patterns](https://docs.djangoproject.com/en/5.0/topics/http/urls/#example). You can think of this component as a secondary, client-side router. Django still handles the primary server-side routes.
2424

2525
We recommend creating a route with a wildcard `.*` to forward routes to ReactPy. For example...
2626
`#!python re_path(r"^/router/.*$", my_reactpy_view)`

docs/src/reference/template-tag.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Each component loaded via this template tag will receive a dedicated WebSocket c
3939

4040
The ReactPy component finder requires that your component path is a string.
4141

42-
**Do not** use Django template/context variables for the component path. Failure to follow this warning will result in components that will not render.
42+
**Do not** use Django template/context variables for the component path. Failure to follow this warning will result in render failures.
4343

4444
For example, **do not** do the following:
4545

@@ -157,7 +157,7 @@ This template tag can be used to insert any number of **client-side** ReactPy co
157157

158158
<!--pyscript-def-start-->
159159

160-
By default, the only dependencies available are the standard Python library, `pyscript`, `pyodide`, `reactpy` core.
160+
By default, the only dependencies available are the Python standard library, `pyscript`, `pyodide`, `reactpy` core.
161161

162162
Your PyScript component file requires a `#!python def root()` component to function as the entry point.
163163

@@ -197,6 +197,8 @@ Your PyScript component file requires a `#!python def root()` component to funct
197197

198198
PyScript components have the ability to directly execute JavaScript using the [`pyodide` `js` module](https://pyodide.org/en/stable/usage/type-conversions.html#importing-javascript-objects-into-python) or [`pyscript` foreign function interface](https://docs.pyscript.net/2024.6.1/user-guide/dom/).
199199

200+
_The `#!python js` module has access to everything within the browser's JavaScript environment. Therefore, any public JavaScript functions loaded within your HTML `#!html <head>` can be called as well. However, be mindful of JavaScript load order!_
201+
200202
=== "root.py"
201203

202204
```python
@@ -279,7 +281,7 @@ Your PyScript component file requires a `#!python def root()` component to funct
279281

280282
## PyScript Setup
281283

282-
This template tag configures the current page to be able to run `pyscript` by loading JavaScript, CSS, and settings values.
284+
This template tag configures the current page to be able to run `pyscript` by loading PyScript's static files.
283285

284286
You can optionally include a list of Python packages to install within the PyScript environment, or a [PyScript configuration dictionary](https://docs.pyscript.net/2024.6.1/user-guide/configuration/).
285287

src/reactpy_django/pyscript/component_template.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def user_workspace_UUID():
1212
to prevent overlapping imports and variable names between different components.
1313
1414
This code is designed to be run directly by PyScript, and is not intended to be run
15-
in a standard Python environment.
15+
in a normal Python environment.
1616
17-
Our template tag performs string substitutions to turn this file into valid PyScript.
17+
ReactPy-Django's template tag performs string substitutions to turn this file into valid PyScript.
1818
"""
1919

2020
def root(): ...

src/reactpy_django/pyscript/layout_handler.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ReactPyLayoutHandler:
77
variable names between user code.
88
99
This code is designed to be run directly by PyScript, and is not intended to be run
10-
in a standard Python environment.
10+
in a normal Python environment.
1111
"""
1212

1313
def __init__(self, uuid):
@@ -87,9 +87,10 @@ def event_handler(*args):
8787

8888
@staticmethod
8989
def delete_old_workspaces():
90-
"""To prevent memory leaks, we must delete all user generated Python code
91-
whe it is no longer on the page. To do this, we compare what UUIDs exist on
92-
the DOM, versus what UUIDs exist within the PyScript global interpreter."""
90+
"""To prevent memory leaks, we must delete all user generated Python code when
91+
it is no longer in use (removed from the page). To do this, we compare what
92+
UUIDs exist on the DOM, versus what UUIDs exist within the PyScript global
93+
interpreter."""
9394
import js
9495

9596
dom_workspaces = js.document.querySelectorAll(".pyscript")

0 commit comments

Comments
 (0)