-
-
Save solson/36bdf5b0272d540896ded5f246981cdc to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let link = (try { | |
let name = s.stream.get("channel")?.get("name")?.as_str()?; | |
(try { | |
let url = format!("https://twitch.tv/{}", name) | |
.parse::<typed_html::types::Uri>().ok()?; | |
html!(<a href={url}>{ text!(name) }</a>): | |
Box<elements::FlowContent<String>> | |
}: Option<Box<elements::FlowContent<String>>>) | |
.unwrap_or_else(|| Box::new(dom::TextNode::new(name))) | |
}: Option<Box<elements::FlowContent<String>>>) | |
.unwrap_or_else(|| html!("<name missing?>")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment