hb

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

README

hb

hb is an experimental HTML builder inspired by Gomponents. It's not aimed at replacing it, I'm justing exploring the possibilities on this space. Checkout the example to see how it works.

Documentation

Index

Constants

View Source
const SlotTag = "<|slot|>"

Variables

View Source
var (
	None = Element{}
)

Functions

func Lazy

func Lazy(el string, attribs *Attributes, children ...Element) func() Element

Types

type Attributes

type Attributes struct {
	// contains filtered or unexported fields
}

func Attr

func Attr(init string) *Attributes

func Case added in v0.3.0

func Case(key string, m map[string]bool) *Attributes

func Comp added in v0.3.0

func Comp(key string, values []string) *Attributes

func Flag added in v0.3.0

func Flag(key string, cond bool) *Attributes

func KV added in v0.4.0

func KV(kvs ...string) *Attributes

func Maybe added in v0.4.0

func Maybe(key, value string, cond bool) *Attributes

func Raw added in v0.3.0

func Raw(key, value string, cond ...bool) *Attributes

func Switch added in v0.3.0

func Switch(key string, idx int, values []string) *Attributes

func (*Attributes) Case

func (attr *Attributes) Case(key string, m map[string]bool) *Attributes

func (*Attributes) Comp added in v0.3.0

func (attr *Attributes) Comp(key string, values []string) *Attributes

func (*Attributes) Flag

func (attr *Attributes) Flag(key string, cond bool) *Attributes

func (*Attributes) KV added in v0.4.0

func (attr *Attributes) KV(kvs ...string) *Attributes

func (*Attributes) Maybe added in v0.4.0

func (attr *Attributes) Maybe(key, value string, cond bool) *Attributes

func (*Attributes) Raw

func (attr *Attributes) Raw(key, value string, cond ...bool) *Attributes

func (*Attributes) String

func (attr *Attributes) String() string

func (*Attributes) Switch

func (attr *Attributes) Switch(key string, idx int, values []string) *Attributes

type Element

type Element struct {
	// contains filtered or unexported fields
}

func E

func E(el string, attribs *Attributes, children ...Element) Element

func Group

func Group(children ...Element) Element

func If

func If(cond bool, then Element, otherwise ...Element) Element

func Map

func Map[S ~[]E, E any](s S, mfn func(E) Element) Element

func Pack added in v0.5.0

func Pack(children []Element) Element

func Template

func Template(raw string, children ...Element) Element

func Text

func Text(text string) Element

func When

func When(cond bool, then func() Element, otherwise ...func() Element) Element

func (*Element) Render

func (el *Element) Render(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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