caspian-utils 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/routing.md +18 -14
- package/package.json +1 -1
package/dist/docs/routing.md
CHANGED
|
@@ -10,10 +10,10 @@ related:
|
|
|
10
10
|
- /docs/components
|
|
11
11
|
- /docs/cache
|
|
12
12
|
- /docs/file-uploads
|
|
13
|
-
- /docs/metadata
|
|
14
|
-
- /docs/pulsepoint
|
|
15
|
-
- /docs/pulsepoint-runtime-map
|
|
16
|
-
- /docs/index
|
|
13
|
+
- /docs/metadata
|
|
14
|
+
- /docs/pulsepoint
|
|
15
|
+
- /docs/pulsepoint-runtime-map
|
|
16
|
+
- /docs/index
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
Caspian follows the same mental model as the Next.js App Router: routes live under `src/app`, folders define URL segments, layouts nest automatically, and special folder names control grouping and dynamic matching.
|
|
@@ -228,7 +228,7 @@ Also bad:
|
|
|
228
228
|
</section>
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Use [pulsepoint.md](./pulsepoint.md) when you need the full authored-vs-rendered example instead of this routing-focused reminder. Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when a route task names a specific PulsePoint directive or SPA behavior and you need the owning runtime file quickly.
|
|
231
|
+
Use [pulsepoint.md](./pulsepoint.md) when you need the full authored-vs-rendered example instead of this routing-focused reminder. Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when a route task names a specific PulsePoint directive or SPA behavior and you need the owning runtime file quickly.
|
|
232
232
|
|
|
233
233
|
### `index.py`
|
|
234
234
|
|
|
@@ -236,6 +236,8 @@ Use `index.py` as the backend companion when a route needs metadata or async ser
|
|
|
236
236
|
|
|
237
237
|
Use `index.py` by itself only for non-visual routes such as redirects or action-only handlers. Because Caspian runs on FastAPI, the page entry should be async when it performs async work.
|
|
238
238
|
|
|
239
|
+
When `page()` calls `render_page(__file__, ...)`, root-validation errors are attributed to the sibling `index.html` because that file is the authored template. If `page()` returns a raw HTML string directly, Caspian treats that value as a runtime fragment instead of an authored template and wraps it in a runtime host root when needed.
|
|
240
|
+
|
|
239
241
|
Example:
|
|
240
242
|
|
|
241
243
|
```python
|
|
@@ -391,20 +393,22 @@ Example root layout:
|
|
|
391
393
|
|
|
392
394
|
If a layout needs shared synchronous props or metadata, add a `layout.py` file next to the HTML layout. Treat it as the backend companion for the layout, not as the place to author visible wrapper markup.
|
|
393
395
|
|
|
396
|
+
When `layout()` calls `render_layout(__file__, ...)`, root-validation errors are attributed to the sibling `layout.html` because that file is the authored template. If `layout()` returns a raw HTML string directly, Caspian treats that value as a runtime fragment instead of an authored template and wraps it in a runtime host root when needed.
|
|
397
|
+
|
|
394
398
|
Example:
|
|
395
399
|
|
|
396
400
|
```python
|
|
397
401
|
from casp.auth import auth
|
|
398
402
|
|
|
399
|
-
def layout(context_data):
|
|
400
|
-
user = auth.get_payload()
|
|
401
|
-
|
|
402
|
-
return {
|
|
403
|
-
"user": user,
|
|
404
|
-
"dashboard_body_class": "w-screen h-screen overflow-hidden",
|
|
405
|
-
"theme": "dark",
|
|
406
|
-
}
|
|
407
|
-
```
|
|
403
|
+
def layout(context_data):
|
|
404
|
+
user = auth.get_payload()
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
"user": user,
|
|
408
|
+
"dashboard_body_class": "w-screen h-screen overflow-hidden",
|
|
409
|
+
"theme": "dark",
|
|
410
|
+
}
|
|
411
|
+
```
|
|
408
412
|
|
|
409
413
|
`context_data` includes URL parameters such as dynamic route values.
|
|
410
414
|
|