Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation - add benefit compared to std lib template #987

Open
surfmuggle opened this issue Nov 3, 2024 · 0 comments
Open

documentation - add benefit compared to std lib template #987

surfmuggle opened this issue Nov 3, 2024 · 0 comments

Comments

@surfmuggle
Copy link

To decide why and how this library can be beneficial add a section / pargraph to the documentation or FAQ.

Motivation

I wanted to understand at least a little why templ was created and found

Building HTML Frontend with Go & Templ - Adrian Hesketh | #HTMXCon2024
channel: The Code Critical

From the video i understood and noted down the following

Reasons to decide for Server Side Rendering

  • Create static pages for Search Enginge Optimization (SEO)
  • Accessibility (for instance UK GDs: page does not need javascript)
  • Team skills (no javscript know how -> learning curve)
  • SPA offers no rendering adavantage since backend must wait for API
  • Performance

Why templ - and what are the stdlib templates shortcomings

  • you can not use arbitary functions {{.Material | toUpper}} inside templates
  • no checks during build - accessing non existing vars {{.Rpice}} fails at run time
  • developer experience is inferior compared to react (JSX) or .Net razor pages
    • Autocompletion
    • Syntax highlghting
    • compiled into MSIL then JIT compiled into machine code

templ - goals and advantages

  • offer autocompletion (templ LSP uses gopls),
  • get compile time errors
  • use go code (func, control flow) inside templates if person.Age == 42 { <p>...<p> }
  • reduce render time (be fast)
  • temple offers hot reload (via watchmode and or vs extension CTRL+R)

Additional context
Something similar above would certainly help to decide to use templ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant