#Is it possible to add pre-formatted text with tags to the component?

1 messages · Page 1 of 1 (latest)

inland notch
#

I get pre-formatted text with tags from the database
let text = r##"h1 {"Title"} p{"Paragraph"}"##.to_string();
or like
let text = "<h1>Title</h1><p>Paragraph</p>".to_string();
Is it possible to create a component with these tags from String like

#[component]
pub fn Text() () -> Element {
rsx! {
   h1 {"Title"}
   p{"Paragraph"}
}}
inland notch
#

How to add native html into tag like div{}? img 👆

 let text = "<h1>Title</h1><p>Paragraph</p>";
 rsx! {
  div { {text} }
}
midnight dagger
#
inland notch
# midnight dagger https://docs.rs/dioxus/0.6.0-alpha.4/dioxus/prelude/global_attributes/constant.d...

Thank's for helps. It works fine.
But what about dioxus html macro
Is it safer or above nice solution too?
Can you @cerulean plank give an expert opinion and whether it would be difficult to upgrade the crate to the latest 0.6 version of dioxus?

let dangerous_inner_html = "<h1>Title</h1><p>Paragraph</p>";
rsx! {
  div { dangerous_inner_html }
}
GitHub

An html macro for dioxus applications. Contribute to DioxusLabs/dioxus-html-macro development by creating an account on GitHub.

cerulean plank
#

dioxus-html-macro is a compile time thing, not runtime. If you do have the html at compile time, you should use rsx-rosetta instead

#

Can you @Evan Almloff give an expert opinion and whether it would be difficult to upgrade the crate to the latest 0.6 version of dioxus?
I would say fairly easy except for ssg and manganis

#

It has a lot less breaking changes then 0.4 -> 0.5

inland notch
cerulean plank
#

Yes

#

Make sure you trust the html though

#

It is dangerous for a reason