Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benpate/html
https://github.com/benpate/html
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/benpate/html
- Owner: benpate
- License: apache-2.0
- Created: 2021-03-13T00:50:51.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-27T01:52:12.000Z (7 months ago)
- Last Synced: 2024-06-27T04:32:11.914Z (7 months ago)
- Language: Go
- Size: 46.9 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html 🚧
[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://pkg.go.dev/github.com/benpate/html)
[![Version](https://img.shields.io/github/v/release/benpate/html?include_prereleases&style=flat-square&color=brightgreen)](https://github.com/benpate/html/releases)
[![Build Status](https://img.shields.io/github/actions/workflow/status/benpate/html/go.yml?style=flat-square)](https://github.com/benpate/html/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/benpate/html?style=flat-square)](https://goreportcard.com/report/github.com/benpate/html)
[![Codecov](https://img.shields.io/codecov/c/github/benpate/html.svg?style=flat-square)](https://codecov.io/gh/benpate/html)## Efficient HTML Tag Assembly
This library builds a string buffer of HTML tags programmatically.
```go
b := html.New()b.Div().Class("wrapper")
b.Div().Class("inner")
b.Form().Attr("action", "my-server")
b.Input().Name("FullName").Value("John Connor").Close()
b.Input().Name("Email").Value("[email protected]").Close()
b.CloseAll()
b.String()
```## Why Builder?
Why not just use [Go Templates](https://golang.org/pkg/text/template/) instead? Templates work great in many cases, but they can be cumbersome when building complex conditional logic directly in your code. Builder uses an efficient [strings.Builder](https://pkg.go.dev/strings#Builder) to assemble the exact HTML you need, and nothing extra.
## Pull Requests Welcome
This library is growing rapidly, as the requirements of its downstram projects continue to evolve. How can it help you build your next masterpiece? Add your voice, because we're all in this together! 🚧