How can templ be Nextjs of Go? #562
Jatin-MYST
started this conversation in
General
Replies: 1 comment 4 replies
-
You can use go code within .templ files to handle logic. templ someComponent(isAdmin bool){
if isAdmin {
<p> admin </p>
} else {
<p>not admin</p>
}
} Same thing applies with looping using range or any other go code. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To A-H and Community,
I wanted to share some thoughts on using Go at our workplace.
We work with websites using Nextjs at the moment.
There is interest in using HTMX, GO, etc.
So, we recently had a discussion about migrating and adopting GO.
The biggest obstacle for us is the loss of JSX. (Specifically the ability to have logic and html in the same place)
It has the best DX for us. I don't know if its just us that feel that way.
Having JSX inside Go to template and create pages would make us jump ship.
Even if its SSR only.
That got me doing some testing to support JSX inside GO.
So, I built a basic transpiler that will convert limited JSX+GO to pure GO.
I bring this up here because Templ is the closest one to this at the moment. (AFAIK)
I wanted to share the idea in case there is ever Templ 2.0
JSX-like syntax support + file system router and maybe Templ can be Nextjs of GO
Thoughts? Please no hate. Valid discussion only.
Here is an example of the transpilation. It simply converts JSX components to Strings.
(Please overlook the bad code. This is just me playing around with the idea):
Beta Was this translation helpful? Give feedback.
All reactions