about summary refs log tree commit diff stats
path: root/README.md
diff options
context:
space:
mode:
authorMarkus Wüstenberg2025-03-05 11:14:06 +0100
committerMarkus Wüstenberg2025-03-05 11:14:06 +0100
commitea676e9a323c7c29b272265a3e19e6f65af397d1 (patch)
tree6246d41440e1ee76f9ea24a6bf7ac10e334511dd /README.md
parent774363ce9c8265efb490a1c164ba6c09ab1dd115 (diff)
downloadgomponents-ea676e9a323c7c29b272265a3e19e6f65af397d1.tar.lz
gomponents-ea676e9a323c7c29b272265a3e19e6f65af397d1.tar.zst
gomponents-ea676e9a323c7c29b272265a3e19e6f65af397d1.zip
Add architecture and FAQ section to readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/README.md b/README.md
index e7aa7da..5ddab8a 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,46 @@ func NavbarLink(href, name, currentPath string) Node {
 For a more complete example, see [the examples directory](internal/examples/).
 There's also the [gomponents-starter-kit](https://github.com/maragudk/gomponents-starter-kit) for a full application template.
 
+## Architecture
+
+gomponents is organized into several packages:
+
+- `gomponents`: Core interfaces and functions like `Node`, `El`, `Attr`, and helpers like `Map`, `Group`, `If`, `Text`, `Raw`.
+- `gomponents/html`: HTML elements and attributes.
+- `gomponents/components`: Higher-level components and utilities.
+- `gomponents/http`: HTTP-related utilities for web servers.
+
+### Void Elements
+
+Void elements in HTML (like `<br>`, `<img>`, `<input>`) don't have closing tags.
+gomponents handles these correctly by checking against an internal list of void elements during rendering.
+When you create a void element, any child nodes that are not attributes will be ignored automatically to ensure valid HTML output.
+
+## Performance Considerations
+
+gomponents renders directly to an `io.Writer`, making it efficient for server-side rendering.
+The library avoids unnecessary allocations where possible.
+
+## FAQ
+
+### Is gomponents production-ready?
+
+Yes! gomponents is mature, stable, fully tested with 100% coverage, and has been used in production by myself and many others.
+
+### Should I choose `html/template`, Templ, or gomponents?
+
+These are all good choices, and it largely comes down to preference.
+I wrote gomponents because I didn't like how I think it's hard to pass data around between templates in `html/template`.
+gomponents is pure Go, with no extra build step like Templ, so it works with all tools that already support Go.
+
+That said, both `html/template` and Templ will do the same thing as gomponents in the end. Try them all and choose what you like!
+
+### I don't like how HTML looks in Go.
+
+First of all, that's not a question. 😉
+
+More seriously, think of gomponents like a DSL for HTML. You're building UI components. Give it a day, and it'll feel natural.
+
 ### What's up with the specially named elements and attributes?
 
 Unfortunately, there are some name clashes in HTML elements and attributes, so they need an `El` or `Attr` suffix,