OMG! No! Having dealt with Go templates in the context of writing Helm charts, I would say this is not a a great idea. Please, invent a better templating language for Go, and then perhaps go down this path. That being said, I am not a great fan of templates in any language. Jinja2 might be a heck of a lot better than Go templates but it can still be hard to get right.
Show HN: Use Go's HTML/template to write React-like code
51–60 of 96 posts
Re: Show HN: Use Go's HTML/template to write React-like code
#52I like the experimentation, but it's still using templates. I was hoping something pure-Go code components without any template rendering at all. I was trying to do the same React-like Component framework, but for Python. No templates needed, you write 100% Python code. Here are some examples how it looks like for simple components: https://github.com/kissgyorgy/compone/tree/master/core/examp... I use it in a Django…
Re: Show HN: Use Go's HTML/template to write React-like code
#53Re: Show HN: Use Go's HTML/template to write React-like code
#54I've been doing something very similar in Rust recently using Askama or Maud for templates (components), optionally with Axum to include a server in the binary. The author mentions wanting to colocate templates with logic, Maud allows much tighter/automatic integration in this regard. This approach also synergizes almost perfectly with HTMX.
Re: Show HN: Use Go's HTML/template to write React-like code
#55Re: Show HN: Use Go's HTML/template to write React-like code
#56I've been doing something very similar in Rust recently using Askama or Maud for templates (components), optionally with Axum to include a server in the binary. The author mentions wanting to colocate templates with logic, Maud allows much tighter/automatic integration in this regard. This approach also synergizes almost perfectly with HTMX.
> Maud allows much tighter/automatic integration in this regard Interesting, can you share some examples?
With Maud, templates/components are only defined once, so you no longer have to worry about keeping the two in sync or colocating them.
This is because Maud provides a macro for writing HTML with Rust-like syntax, so all your HTML (components) ends up inside regular Rust files, and you can refer to variables as usual.
This really makes for almost seamless integration between Rust code and the HTML you serve.
Re: Show HN: Use Go's HTML/template to write React-like code
#57[off-topic comment but somewhat relevant for anyone choosing a lang/ecosystem] I noticed that the syntax highlighting for the Go html/template examples in the article is incomplete. We're using Go html/templates on a new project (within a team that does a lot of React frontend & some Python) so this kind of project seems like it would really suit, but a massive bugbear has been the very poor IDE-level syntax highligh…
In Jet Brains family IDEs (not sure how they call the go one) you can use Inject language or reference option to get most of editor support (inspections,highlighting,intellisense etc.) for snippets of one language embedd in files of another language. I've been using it with JS scripts inside custom xml for a while and it works pretty well.
Re: Show HN: Use Go's HTML/template to write React-like code
#58Interesting. I am actually doubling down on building web apps in Go using mostly standard library, powerful templates and sprinkle in with a library such as Alpine JS. Seeing some success so far and it makes me so much happier knowing that I don't have to deal with node_modules BS (well may be except tailwind for css). I actually want to test the limits of how far one can go without using a JS framework like React/Vu…
Re: Show HN: Use Go's HTML/template to write React-like code
#59I've been doing something very similar in Rust recently using Askama or Maud for templates (components), optionally with Axum to include a server in the binary. The author mentions wanting to colocate templates with logic, Maud allows much tighter/automatic integration in this regard. This approach also synergizes almost perfectly with HTMX.
I do this but using hypertext, since the syntax is closer to JSX and less confusing for others to touch.
Re: Show HN: Use Go's HTML/template to write React-like code
#60My style for building web app. I was never convinced that doing everything on JS layer is a good thing (regardless the backend language). But you need to show more interactivity to convince the JS people. I personally like this style and add HTMX for partial updates.