diff options
author | Markus Wüstenberg | 2020-09-21 16:30:29 +0200 |
---|---|---|
committer | GitHub | 2020-09-21 16:30:29 +0200 |
commit | c832941edb5e896a893c663e83aba7088ea40e6c (patch) | |
tree | 7ec681a7b0d793e98716aa58b839d97dd59a7f2e /README.md | |
parent | 18b52ffda17b2c2a5b888260f3199fd002162b98 (diff) | |
download | gomponents-c832941edb5e896a893c663e83aba7088ea40e6c.tar.lz gomponents-c832941edb5e896a893c663e83aba7088ea40e6c.tar.zst gomponents-c832941edb5e896a893c663e83aba7088ea40e6c.zip |
Add simple example (#13)
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/README.md b/README.md index 5d15060..cd18771 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,36 @@ without the use of a template language. Think server-side-rendered React, but without the virtual DOM and diffing. The implementation is still incomplete, but usable. The API may change until version 1 is reached. + +## Usage + +Get the library using `go get`: + +```shell script +go get -u github.com/maragudk/gomponents +``` + +Then do something like this: + +```go +package foo + +import ( + "net/http" + + g "github.com/maragudk/gomponents" + "github.com/maragudk/gomponents/el" +) + +func main() { + _ = http.ListenAndServe("localhost:8080", handler()) +} + +func handler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + _ = g.Write(w, el.Document(el.HTML(el.Head(el.Title("Hi!")), el.Body(el.H1("Hi!"))))) + } +} +``` + +For more complete examples, see [the examples directory](examples/). |