I am trying to bind properly rel attribute. I know some people would say “just use a string”, but I want something safer.
A poly-variant isn’t enough as rel can contains multiple values (eg: “ugc, nofollow”).
Is there any trick to bind this properly with the ability to pass a simple polyvariant or an array of it, keeping this zero-cost?
It’s for JSX. I mentioned html because at the end it’s for html output. But in my case it’s for react native web
I wish I could write <Text href rel=#ugc> or <Text href rel=[#ugc, #nofollow]>.
I guess rescript should allow something like <Text href rel=#one(ugc)> or <Text href rel=#many([#ugc, #nofollow])>. I remember there were something named @unwrap but it cannot be used for react component prop binding if I am correct.
It does impose an extra cognitive burden. But I think all other methods would impose just as much if not more…? Good thing we have decent autocomplete and type hint nowadays. That + put some prominent examples, and you should be good to go.
Note even with this, some invariant is still not encoded like you can pass duplicate names like toString( list {#ugc, #ugc}), so I am not sure if it is worth it.