Skip to content

Commit 53c0499

Browse files
committed
component and template tag docs
1 parent eb72c4f commit 53c0499

39 files changed

+671
-136
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ Using the following categories, list your changes in this order:
3434

3535
## [Unreleased]
3636

37+
### Added
38+
39+
- Client-side Python components can now be rendered via the new `pyscript_component` template tag
40+
- Client-side components can be embedded into existing server-side components via `reactpy_django.components.pyscript_component`.
41+
- 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.
42+
3743
### Changed
3844

3945
- New syntax for `use_query` and `use_mutation` hooks. Here's a quick comparison of the changes:
4046

4147
```python
42-
query = use_query(QueryOptions(thread_sensitive=True), get_items, value=123456, foo="bar") # Old
43-
query = use_query(get_items, {"value":12356, "foo":"bar"}, thread_sensitive=True) # New
48+
query = use_query(QueryOptions(thread_sensitive=True), get_items, foo="bar") # Old
49+
query = use_query(get_items, {"foo":"bar"}, thread_sensitive=True) # New
4450

4551
mutation = use_mutation(MutationOptions(thread_sensitive=True), remove_item) # Old
4652
mutation = use_mutation(remove_item, thread_sensitive=True) # New
@@ -50,6 +56,10 @@ Using the following categories, list your changes in this order:
5056

5157
- `QueryOptions` and `MutationOptions` have been removed. Their values are now passed direct into the hook.
5258

59+
### Fixed
60+
61+
- Resolved a bug where Django-ReactPy would not properly detect `settings.py:DEBUG`.
62+
5363
## [3.8.1] - 2024-05-07
5464

5565
### Added

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy Django
1+
# <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy-Django
22

33
<p>
44
<a href="https://github.com/reactive-python/reactpy-django/actions?query=workflow%3ATest">
@@ -21,6 +21,7 @@
2121
[ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**. This package also turbocharges ReactPy with features such as...
2222

2323
- [SEO compatible rendering](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_prerender)
24+
- [Client-Side Python components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/#pyscript-component)
2425
- [Single page application (SPA) capabilities](https://reactive-python.github.io/reactpy-django/latest/reference/router/#django-router)
2526
- [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
2627
- [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
@@ -82,7 +83,7 @@ def hello_world(recipient: str):
8283

8384
<!--py-code-end-->
8485

85-
## [`my_app/templates/my-template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
86+
## [`my_app/templates/my_template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
8687

8788
<!--html-header-start-->
8889

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% load reactpy %}
2+
<!DOCTYPE html>
3+
<html>
4+
5+
<head>
6+
<title>ReactPy</title>
7+
{% pyscript_setup %}
8+
</head>
9+
10+
<body>
11+
{% pyscript_component "./example_project/my_app/components/hello_world.py" %}
12+
</body>
13+
14+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<body>
2+
{% pyscript_component "./example_project/my_app/components/root.py" initial=my_initial_object %}
3+
</body>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<body>
2+
{% pyscript_component "./example_project/my_app/components/root.py" initial="<div> Loading ... </div>" %}
3+
</body>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% load reactpy %}
2+
<!DOCTYPE html>
3+
<html>
4+
5+
<head>
6+
<title>ReactPy</title>
7+
{% pyscript_setup %}
8+
</head>
9+
10+
<body>
11+
{% pyscript_component "./example_project/my_app/components/root.py"
12+
"./example_project/my_app/components/child.py" %}
13+
</body>
14+
15+
</html>

docs/examples/html/pyscript-root.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<body>
2+
{% pyscript_component "./example_project/my_app/components/main.py" root="main" %}
3+
</body>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<head>
2+
<title>ReactPy</title>
3+
{% pyscript_setup config=my_config_object %}
4+
</head>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<head>
2+
<title>ReactPy</title>
3+
{% pyscript_setup config="{'experimental_create_proxy':'auto'}" %}
4+
</head>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<head>
2+
<title>ReactPy</title>
3+
{% pyscript_setup "dill==0.3.5" "markdown<=3.6.0" "nest_asyncio" "titlecase" %}
4+
</head>

0 commit comments

Comments
 (0)