From a560bca85d185336b489014265d429f53acbeac8 Mon Sep 17 00:00:00 2001 From: Yuri Date: Wed, 3 May 2017 21:21:57 -0400 Subject: [PATCH] Improve the documentation of routing parameters I was stuck on this for a while earlier today: it turns out that `m.route.param` will not return the right results in the `onmatch` function on a `RouterResolver`, though it will inside of a `render` function on the same. This behavior is documented in the `onmatch` section but not the `m.route.param` section, which is where I was looking when I ran up against this earlier. From an API design perspective it would make sense to me for `m.route.param` to return valid results inside `onmatch`, but I don't know enough about Mithril's internals to know how complex it would be to implement. --- docs/route.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/route.md b/docs/route.md index 518f248d..b224a6f4 100644 --- a/docs/route.md +++ b/docs/route.md @@ -124,7 +124,7 @@ Argument | Type | Required | Description ##### m.route.param -Retrieves a route parameter. A route parameter is a key-value pair. Route parameters may come from a few different places: +Retrieves a route parameter. A route parameter is a key-value pair. Note that in the `onmatch` function of a RouterResolver, route parameters are unavailable from `m.route.param` and are passed as an argument instead due to internal timing of the route resolution mechanism. Route parameters may come from a few different places: - route interpolations (e.g. if a route is `/users/:id`, and it resolves to `/users/1`, the route parameter has a key `id` and value `"1"`) - router querystrings (e.g. if the path is `/users?page=1`, the route parameter has a key `page` and value `"1"`)