I love the idea! I could imagine something similar created for other languages too. Perhaps written in a way that a template could be reused in, let's say Django, and a JS React frontend. With all the type-safety that tsx provides.
riffraff 5 minutes ago [-]
There was a brief period where everyone and their dog implemented mustache[0] as a template system, but it died quickly because cross-language templating is not that useful in the end, you seldom need to switch host language but keep the templates.
As for Django... well.. Django only has text formatting, you can write any garbage and broken html and lots of invalid templates with silent failures there unfortunately.
i prefer it, but you can also get html if you want
eg
html! {
<div onclick=|_ev: web_sys::MouseEvent| {}>
You can type text right into the elements
{ component }
{ text_var }
</div>
};
skavi 27 minutes ago [-]
but you have invented syntax
asimovDev 1 hours ago [-]
This is just Twig templates, crazy. It's cool that Rust can do this out of a box
slopinthebag 1 hours ago [-]
yep and you get rust's lsp support too, autoformatting, etc.
this is rsx, but there are other macros that look just like html. i prefer this though, it's much more compact and readable imo
lukaslalinsky 11 minutes ago [-]
I'm not a fan of Rust, the overly flexible macros are actually one reason for it, but if you can indeed get LSP support in a custom syntax like this, that's really awesome. Thank you for the example.
https://web.dev/articles/imports
Been there, tried that.
Introduced in 2014 (Chrome 36) Deprecated 2018 (Chrome 70) Retired 2019 (Chrome 73)
Why is there no direct support for templating in HTML itself?
(but yes- I used these a lot like 25 years ago)
0: https://en.wikipedia.org/wiki/Mustache_(template_system)
For examples, see http://www.impredicative.com/ur/demo/
As for Django... well.. Django only has text formatting, you can write any garbage and broken html and lots of invalid templates with silent failures there unfortunately.
https://kotlinlang.org/docs/type-safe-builders.html
That's not HTML though, you have to learn a whole new dsl that must conform to rust parser rules. So, not the same thing at all.
eg
this is rsx, but there are other macros that look just like html. i prefer this though, it's much more compact and readable imo