Description
I'm currently reviewing a PR that moves https://docs.rs/mox from snax to syn-rsx and I quite like most of what we get out of the change. One thing we're having to give up, though, is the ability to add sigils to the delimiters of expressions we parse in order to have a shorthand for string formatters, like this:
let button = mox! {
<button onclick={move |_| set_value.update(|n| Some(n + 1))}>
{% "{} ({})", text, value }
</button>
};
I chose {% ... }
for the delimiters because it was (a) easy enough to implement with snax, (b) didn't collide with other common rust sigils and (c) reminded me of python's formatter sigil. Definitely open to alternative ways of spelling it out.
With the switch to syn-rsx, the above becomes:
let button = mox! {
<button onclick = move |_| set_value.update(|n| Some(n + 1))>
{format_args!("{} ({})", text, value)}
</button>
};
I'm of the opinion that formatting strings for XML-ish things is a common-enough operation that it deserves a shorthand, although I'll note that JSX itself gets by just fine without it. I'll also note that JS has tilde-format-strings, which we don't :*(. What do you think?
Activity