You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/reference/template-tag.md
+28-22Lines changed: 28 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ This template tag can be used to insert any number of ReactPy components onto yo
28
28
| `#!python key` | `#!python Any` | Force the component's root node to use a [specific key value](https://reactpy.dev/docs/guides/creating-interfaces/rendering-data/index.html#organizing-items-with-keys). Using `#!python key` within a template tag is effectively useless. | `#!python None` |
29
29
| `#!python host` | `#!python str | None` | The host to use for the ReactPy connections. If unset, the host will be automatically configured.<br/>Example values include: `localhost:8000`, `example.com`, `example.com/subdir` | `#!python None` |
30
30
| `#!python prerender` | `#!python str` | If `#!python "True"`, the component will pre-rendered, which enables SEO compatibility and reduces perceived latency. | `#!python "False"` |
31
+
| `#!python offline` | `#!python str` | The dotted path to a component that will be displayed if your root component loses connection to the server. Keep in mind, this `offline` component will be non-interactive (hooks won't operate). | `#!python ""` |
31
32
| `#!python **kwargs` | `#!python Any` | The keyword arguments to provide to the component. | N/A |
32
33
33
34
<font size="4">**Returns**</font>
@@ -66,26 +67,6 @@ This template tag can be used to insert any number of ReactPy components onto yo
66
67
67
68
<!--context-end-->
68
69
69
-
??? question "Can I render components on a different server (distributed computing)?"
70
-
71
-
Yes! This is most commonly done through [`settings.py:REACTPY_HOSTS`](../reference/settings.md#reactpy_default_hosts). However, you can use the `#!python host` keyword to render components on a specific ASGI server.
This configuration most commonly involves you deploying multiple instances of your project. But, you can also create dedicated Django project(s) that only render specific ReactPy components if you wish.
82
-
83
-
Here's a couple of things to keep in mind:
84
-
85
-
1. If your host address are completely separate ( `origin1.com != origin2.com` ) you will need to [configure CORS headers](https://pypi.org/project/django-cors-headers/) on your main application during deployment.
86
-
2. You will not need to register ReactPy WebSocket or HTTP paths on any applications that do not perform any component rendering.
87
-
3. Your component will only be able to access your template tag's `#!python *args`/`#!python **kwargs` if your applications share a common database.
88
-
89
70
<!--multiple-components-start-->
90
71
91
72
??? question "Can I use multiple components on one page?"
@@ -111,7 +92,6 @@ This template tag can be used to insert any number of ReactPy components onto yo
111
92
Additionally, in scenarios where you are trying to create a Single Page Application (SPA) within Django, you will only have one component within your `#!html <body>` tag.
112
93
113
94
<!--multiple-components-end-->
114
-
<!--args-kwargs-start-->
115
95
116
96
??? question "Can I use positional arguments instead of keyword arguments?"
117
97
@@ -129,4 +109,30 @@ This template tag can be used to insert any number of ReactPy components onto yo
129
109
{% include "../../python/template-tag-args-kwargs.py" %}
130
110
```
131
111
132
-
<!--args-kwargs-end-->
112
+
??? question "Can I render components on a different server (distributed computing)?"
113
+
114
+
Yes! This is most commonly done through [`settings.py:REACTPY_HOSTS`](../reference/settings.md#reactpy_default_hosts). However, you can use the `#!python host` keyword to render components on a specific ASGI server.
This configuration most commonly involves you deploying multiple instances of your project. But, you can also create dedicated Django project(s) that only render specific ReactPy components if you wish.
125
+
126
+
Here's a couple of things to keep in mind:
127
+
128
+
1. If your host address are completely separate ( `origin1.com != origin2.com` ) you will need to [configure CORS headers](https://pypi.org/project/django-cors-headers/) on your main application during deployment.
129
+
2. You will not need to register ReactPy WebSocket or HTTP paths on any applications that do not perform any component rendering.
130
+
3. Your component will only be able to access your template tag's `#!python *args`/`#!python **kwargs` if your applications share a common database.
131
+
132
+
??? question "Can I pre-render components for SEO compatibility?"
133
+
134
+
...
135
+
136
+
??? question "How do I show something when the client disconnects?"
0 commit comments