diff --git a/pagetop-homedemo/src/lib.rs b/pagetop-homedemo/src/lib.rs index 28e4c056..ae0d8824 100644 --- a/pagetop-homedemo/src/lib.rs +++ b/pagetop-homedemo/src/lib.rs @@ -142,7 +142,7 @@ fn about_pagetop() -> Container { .with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALES_HOMEDEMO))) .with_component(Paragraph::with( L10n::e("pagetop_text3", &LOCALES_HOMEDEMO) - .with_arg("href", "https://docs.rs/pagetop/latest/pagetop".to_string()), + .with_arg("href", "https://docs.rs/pagetop/latest/pagetop"), )), ), ) diff --git a/pagetop/src/core/component/l10n.rs b/pagetop/src/core/component/l10n.rs index 5829c943..d014dea7 100644 --- a/pagetop/src/core/component/l10n.rs +++ b/pagetop/src/core/component/l10n.rs @@ -96,8 +96,8 @@ impl L10n { } #[fn_builder] - pub fn alter_arg(&mut self, arg: &'static str, value: String) -> &mut Self { - self.args.insert(arg, value); + pub fn alter_arg(&mut self, arg: &'static str, value: impl Into) -> &mut Self { + self.args.insert(arg, value.into()); self } @@ -115,4 +115,8 @@ impl L10n { pub fn args(&self) -> &HashMap<&str, String> { &self.args } + + pub fn into_string(&self, cx: &mut Context) -> Option { + self.prepare_component(cx).into_string() + } } diff --git a/pagetop/src/html.rs b/pagetop/src/html.rs index c0ebacc5..a67d8274 100644 --- a/pagetop/src/html.rs +++ b/pagetop/src/html.rs @@ -39,4 +39,12 @@ impl PrepareMarkup { PrepareMarkup::With(markup) => markup, } } + + pub fn into_string(self) -> Option { + match self { + PrepareMarkup::None => None, + PrepareMarkup::Text(text) => Some(text.to_string()), + PrepareMarkup::With(markup) => Some(markup.into_string()), + } + } }