44
55
66@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 ):
178 location = use_location ()
189 query = use_query ()
10+ params = use_params ()
1911
20- route_info = html ._ (
12+ return html ._ (
13+ html .div ({"id" : "router-string" }, string ),
14+ html .div (f"Params: { params } " ),
2115 html .div (
2216 {"id" : "router-path" , "data-path" : location .pathname },
2317 f"Path Name: { location .pathname } " ,
@@ -26,17 +20,26 @@ def main():
2620 html .div (f"Query: { query } " ),
2721 )
2822
23+
24+ @component
25+ def main ():
2926 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" ))),
3835 route (
3936 "/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" )),
4144 ),
4245 )
0 commit comments