Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's using this: https://yew.rs/docs/concepts/html and no, just like JSX, it's not HTML strings. It's building HTML-like AST in macro.

One great thing about JSX (and Yew) is that it's way more secure way to build an HTML, because you don't need to worry about escaping behaviors as much. (Sometimes you still need, like injecting inline CSS etc. but not that often)



whoa, so you can write like a DSL parser using the rust macro matcher syntax?


Essentially yes. Macros in Rust are very powerful, similar to Lisp macros (although they are naturally clunkier).

As you would expect, you will find macros for HTML, JSON etc. in libraries, but there are also quite a bunch of smaller, frequent macros that simply reduce common boilerplate.


And then there are the Rust macros that let you write code in Lisp syntax, although I don't recall that any of them had a defmacro form…


Oh god, what have I seen


I'm sorry; I should have thought about the more sensitive readers.


rust allows for procedural macros (basically a function that takes a token stream and returns a token stream, and yes you can do parsing in this funciton

https://doc.rust-lang.org/reference/procedural-macros.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: