html

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 2 Imported by: 4

README

libhtml

Simple HTML library for Go.

Install

go get github.com/hypercodehq/libhtml

Usage

package main

import (
	"net/http"

	"github.com/hypercodehq/libhtml"
	"github.com/hypercodehq/libhtml/attr"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		doc := html.Document(
			html.HTML(
				html.Head(html.Title(html.Text("Hello"))),
				html.Body(html.H1(html.Text("Hello, World!"))),
			),
		)
		doc.Render(w, r)
	})
	http.ListenAndServe(":8080", nil)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Document

func Document(root Node) document

Types

type Attributer

type Attributer interface {
	Node
	GetAttribute() (key, value string)
}

type Node

type Node interface {
	Render(w http.ResponseWriter, r *http.Request) error
}

func A

func A(children ...Node) Node

func Body

func Body(children ...Node) Node

func Button

func Button(children ...Node) Node

func Details

func Details(children ...Node) Node

func Div

func Div(children ...Node) Node

func Element

func Element(tag string, children ...Node) Node
func Footer(children ...Node) Node

func For

func For[T any](items []T, fn func(T) Node) Node

func Form

func Form(children ...Node) Node

func Group

func Group(children ...Node) Node

Group renders multiple children without wrapping them in an HTML element. This is useful when you need to return multiple nodes as a single Node.

func H1

func H1(children ...Node) Node

func H2

func H2(children ...Node) Node

func H3

func H3(children ...Node) Node

func HTML

func HTML(children ...Node) Node
func Head(children ...Node) Node
func Header(children ...Node) Node

func Hr

func Hr(children ...Node) Node

func If

func If(condition bool, node Node) Node

func IfElse

func IfElse(condition bool, thenNode Node, elseNode Node) Node

func IfElsef

func IfElsef(condition bool, thenFn func() Node, elseFn func() Node) Node

func Iff

func Iff(condition bool, fn func() Node) Node

func Img

func Img(children ...Node) Node

func Input

func Input(children ...Node) Node

func Label

func Label(children ...Node) Node

func Li

func Li(children ...Node) Node
func Link(children ...Node) Node

func Main

func Main(children ...Node) Node

func Meta

func Meta(children ...Node) Node
func Nav(children ...Node) Node

func Option

func Option(children ...Node) Node

func P

func P(children ...Node) Node

func Script

func Script(children ...Node) Node

func Section

func Section(children ...Node) Node

func Select

func Select(children ...Node) Node

func Span

func Span(children ...Node) Node

func Summary

func Summary(children ...Node) Node

func Table

func Table(children ...Node) Node

func Tbody

func Tbody(children ...Node) Node

func Td

func Td(children ...Node) Node

func Text

func Text(content string) Node

func Textarea

func Textarea(children ...Node) Node

func Title

func Title(children ...Node) Node

func Tr

func Tr(children ...Node) Node

func Ul

func Ul(children ...Node) Node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL