yoshuawuyts / html

Type-safe HTML support for Rust
Apache License 2.0
244 stars 7 forks source link

naming of functions on builder #62

Open ModProg opened 1 year ago

ModProg commented 1 year ago

I want to implement a rsx like macro:

rsx! {
<div>
    <img />
    <a> </a>
    <audio/>
</div>
}

That would roughly generate something like

Division::builder()
    .image()
    .anchor()
    .audio()
    // ...

That generates html, and wanted to use this crate for the type safe generation of the html.

One issue I have, then, is that for some elements like audio it would be easy to map to the builder functions, but some like a or img I need to translate to anchor and image respectively.

Is there a list of all of these mappings? Or could html somehow provide such an interface that uses the actual tags as function names. The latter is probably a high ask for something that maybe I have the only usecase for.