fitzgen / dodrio

A fast, bump-allocated virtual DOM library for Rust and WebAssembly.
https://docs.rs/dodrio
Mozilla Public License 2.0
1.24k stars 49 forks source link

Demonstrate a macro for helping with building elements. #152

Open richard-uk1 opened 4 years ago

richard-uk1 commented 4 years ago

I'm not really advocating for merging this, rather I'm drawing your attention to its existence. I got bored of writing out the builder methods verbatim, so I made a macro to do codegen for me a la jsx. It can do some transformations for you, but you've always got a {} get-out, where tokens in the braces are just copied verbatim. It also uses a style lib I've been working on to typecheck css styles at compiletime.

Anyway as I said, just sharing in case it is interesting to anyone.

richard-uk1 commented 4 years ago

Any questions feel free to ask. :)

fitzgen commented 4 years ago

Neat! This isn't really something I want to merge into dodrio itself, but I encourage tinkering with it as its own crate!

fitzgen commented 4 years ago

Do you have an example of usage anywhere?

richard-uk1 commented 4 years ago

I am actually using this live in a production website (https://scrumbles.uk). Maybe not wise, but seems to be working well.