4
4
5
5
6
6
@component
7
- def display_params (* args ):
8
- params = use_params ()
9
- return html ._ (
10
- html .div (f"Params: { params } " ),
11
- * args ,
12
- )
13
-
14
-
15
- @component
16
- def main ():
7
+ def display_params (string : str ):
17
8
location = use_location ()
18
9
query = use_query ()
10
+ params = use_params ()
19
11
20
- route_info = html ._ (
12
+ return html ._ (
13
+ html .div ({"id" : "router-string" }, string ),
14
+ html .div (f"Params: { params } " ),
21
15
html .div (
22
16
{"id" : "router-path" , "data-path" : location .pathname },
23
17
f"Path Name: { location .pathname } " ,
@@ -26,17 +20,26 @@ def main():
26
20
html .div (f"Query: { query } " ),
27
21
)
28
22
23
+
24
+ @component
25
+ def main ():
29
26
return django_router (
30
- route ("/router/" , html . div ("Path 1" , route_info )),
31
- route ("/router/any/<value>/" , display_params ("Path 2" , route_info )),
32
- route ("/router/integer/<int:value>/" , display_params ("Path 3" , route_info )),
33
- route ("/router/path/<path:value>/" , display_params ("Path 4" , route_info )),
34
- route ("/router/slug/<slug:value>/" , display_params ("Path 5" , route_info )),
35
- route ("/router/string/<str:value>/" , display_params ("Path 6" , route_info )),
36
- route ("/router/uuid/<uuid:value>/" , display_params ("Path 7" , route_info )),
37
- route ("/router/" , None , route ("abc/" , display_params ("Path 8" , route_info ))),
27
+ route ("/router/" , display_params ("Path 1" )),
28
+ route ("/router/any/<value>/" , display_params ("Path 2" )),
29
+ route ("/router/integer/<int:value>/" , display_params ("Path 3" )),
30
+ route ("/router/path/<path:value>/" , display_params ("Path 4" )),
31
+ route ("/router/slug/<slug:value>/" , display_params ("Path 5" )),
32
+ route ("/router/string/<str:value>/" , display_params ("Path 6" )),
33
+ route ("/router/uuid/<uuid:value>/" , display_params ("Path 7" )),
34
+ route ("/router/" , None , route ("abc/" , display_params ("Path 8" ))),
38
35
route (
39
36
"/router/two/<int:value>/<str:value2>/" ,
40
- display_params ("Path 9" , route_info ),
37
+ display_params ("Path 9" ),
38
+ ),
39
+ route (
40
+ "/router/star/" ,
41
+ None ,
42
+ route ("one/" , display_params ("Path 11" )),
43
+ route ("*" , display_params ("Path 12" )),
41
44
),
42
45
)
0 commit comments