pub fn href(pattern: &str) -> HrefExpand description
Builds a url from a route pattern, percent-encoding the parameters, so that the router matches it and decodes the same values.
use egui_kit::href;
use serde::Serialize;
#[derive(Serialize)]
struct BlogQuery {
tag: Option<String>,
page: u32,
}
let url = href("/blog/{slug}").param("slug", "hello world");
assert_eq!(url.to_string(), "/blog/hello%20world");
let query = BlogQuery { tag: Some("egui".into()), page: 2 };
let url = href("/{?lang}/blog").query(&query).fragment("top");
assert_eq!(url.to_string(), "/blog?tag=egui&page=2#top");Nav::goto and friends take it directly,
Nav::link as &href(..).to_string().
Panics on an invalid pattern, like Router::page. Turning it into a
url panics if a required parameter is missing.