hatmill/README.md

39 lines
2.1 KiB
Markdown

hatmill - HTML generation DSL for Go
=====================================
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://git.codemonkeysoftware.net/b/hatmill/blob/master/COPYING)
[![Gitlab pipeline status](https://git.codemonkeysoftware.net/b/hatmill/badges/master/pipeline.svg)](https://git.codemonkeysoftware.net/b/hatmill/commits/master)
[![Go Report Card](https://goreportcard.com/badge/git.codemonkeysoftware.net/b/hatmill)](https://goreportcard.com/report/git.codemonkeysoftware.net/b/hatmill)
[![GoDoc](https://godoc.org/git.codemonkeysoftware.net/b/hatmill?status.svg)](https://godoc.org/git.codemonkeysoftware.net/b/hatmill)
![Badge count](https://img.shields.io/badge/badges-5-yellow.svg)
`hatmill` provides a simple set of types and helper functions for writing HTML in plain Go code, without having to deal with any template languages. It is not spectacularly fast, but is comparable in simple cases to the `html/template` package; run `go test -bench=. -benchmem` for proof. `hatmill` “templates” are arguably easier to read and write than many template languages.
`hatmill` uses [semantic versioning](https://semver.org/).
Installation
---------------
There are three necessary packages:
- `git.codemonkeysoftware.net/b/hatmill`
- `git.codemonkeysoftware.net/b/hatmill/attribute`
- `git.codemonkeysoftware.net/b/hatmill/element`
Install them as you would any other Go package, with `go get` or whatever.
`git.codemonkeysoftware.net/b/hatmill` is a Go module and so will play nicely
with Go ≥ 1.11.
Usage
------
Basic types are in `git.codemonkeysoftware.net/b/hatmill`. The `attribute`
and `element` subpackages contain helper functions for HTML5 attributes and
elements. See the `Example` function in `hatmill_test.go`.
Hacking
--------
If there is a missing attribute or element helper function, describe it in
`defs.json` and run `go generate` in the repository root. If you can't figure
out what you need to know by reading `defs.json`, `internal/codegen/*`,
`attribute/*`, and `element/*`, then
[pester me](https://git.codemonkeysoftware.net/b/hatmill/issues/new) to
improve the documentation.