🚧 Ajustes menores en rutas y localización
- Añade `Route::try_resolve()` y `RoutePath::is_empty()` para omitir atributos HTML opcionales cuando la ruta resultante está vacía. - Renombra `Locale::configured_langid()` a `try_langid()` (convención `try_*` para Option). - Reordena include_locales! y otros cambios menores.
This commit is contained in:
parent
8573aca29e
commit
b9d9cdf601
6 changed files with 22 additions and 7 deletions
|
|
@ -144,6 +144,15 @@ impl Route {
|
|||
pub fn resolve(&self, cx: &Context) -> RoutePath {
|
||||
(self.0)(cx)
|
||||
}
|
||||
|
||||
/// Como [`resolve()`](Self::resolve), pero devuelve `None` cuando la ruta calculada está vacía.
|
||||
///
|
||||
/// Útil para atributos HTML opcionales (por ejemplo `href`) que no deben renderizarse si la
|
||||
/// ruta resultante no tiene contenido.
|
||||
pub fn try_resolve(&self, cx: &Context) -> Option<RoutePath> {
|
||||
let route = self.resolve(cx);
|
||||
(!route.is_empty()).then_some(route)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Route {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue