html

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

libhtml

Apache-2.0 license

Join Discord

A simple library to write HTML in plain Go.

Installation

go get github.com/alexisbcz/libhtml

Usage

yet to be written

Acknowledgements

Thanks to the awesome work from gostar, htmlgo and gomponents which inspired me to create yet another HTML in plain Go library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A

func A(children ...Node) *a

A creates a new a element Allows optional child nodes to be passed during creation

func Abbr

func Abbr(children ...Node) *abbr

Abbr creates a new abbr element Allows optional child nodes to be passed during creation

func Address

func Address(children ...Node) *address

Address creates a new address element Allows optional child nodes to be passed during creation

func Area

func Area(children ...Node) *area

Area creates a new area element Allows optional child nodes to be passed during creation

func Article

func Article(children ...Node) *article

Article creates a new article element Allows optional child nodes to be passed during creation

func Aside

func Aside(children ...Node) *aside

Aside creates a new aside element Allows optional child nodes to be passed during creation

func Audio

func Audio(children ...Node) *audio

Audio creates a new audio element Allows optional child nodes to be passed during creation

func B

func B(children ...Node) *b

B creates a new b element Allows optional child nodes to be passed during creation

func Base

func Base(children ...Node) *base

Base creates a new base element Allows optional child nodes to be passed during creation

func Bdi

func Bdi(children ...Node) *bdi

Bdi creates a new bdi element Allows optional child nodes to be passed during creation

func Bdo

func Bdo(children ...Node) *bdo

Bdo creates a new bdo element Allows optional child nodes to be passed during creation

func Blockquote

func Blockquote(children ...Node) *blockquote

Blockquote creates a new blockquote element Allows optional child nodes to be passed during creation

func Body

func Body(children ...Node) *body

Body creates a new body element Allows optional child nodes to be passed during creation

func Br

func Br(children ...Node) *br

Br creates a new br element Allows optional child nodes to be passed during creation

func Button

func Button(children ...Node) *button

Button creates a new button element Allows optional child nodes to be passed during creation

func Canvas

func Canvas(children ...Node) *canvas

Canvas creates a new canvas element Allows optional child nodes to be passed during creation

func Caption

func Caption(children ...Node) *caption

Caption creates a new caption element Allows optional child nodes to be passed during creation

func Circle

func Circle(children ...Node) *circle

Circle creates a new circle element Allows optional child nodes to be passed during creation

func Cite

func Cite(children ...Node) *cite

Cite creates a new cite element Allows optional child nodes to be passed during creation

func Code

func Code(children ...Node) *code

Code creates a new code element Allows optional child nodes to be passed during creation

func Col

func Col(children ...Node) *col

Col creates a new col element Allows optional child nodes to be passed during creation

func Colgroup

func Colgroup(children ...Node) *colgroup

Colgroup creates a new colgroup element Allows optional child nodes to be passed during creation

func Data

func Data(children ...Node) *data

Data creates a new data element Allows optional child nodes to be passed during creation

func Datalist

func Datalist(children ...Node) *datalist

Datalist creates a new datalist element Allows optional child nodes to be passed during creation

func Dd

func Dd(children ...Node) *dd

Dd creates a new dd element Allows optional child nodes to be passed during creation

func Del

func Del(children ...Node) *del

Del creates a new del element Allows optional child nodes to be passed during creation

func Details

func Details(children ...Node) *details

Details creates a new details element Allows optional child nodes to be passed during creation

func Dfn

func Dfn(children ...Node) *dfn

Dfn creates a new dfn element Allows optional child nodes to be passed during creation

func Dialog

func Dialog(children ...Node) *dialog

Dialog creates a new dialog element Allows optional child nodes to be passed during creation

func Div

func Div(children ...Node) *div

Div creates a new div element Allows optional child nodes to be passed during creation

func Dl

func Dl(children ...Node) *dl

Dl creates a new dl element Allows optional child nodes to be passed during creation

func Document

func Document(children ...Node) *document

Document creates a complete HTML document with the given children

func Dt

func Dt(children ...Node) *dt

Dt creates a new dt element Allows optional child nodes to be passed during creation

func Ellipse

func Ellipse(children ...Node) *ellipse

Ellipse creates a new ellipse element Allows optional child nodes to be passed during creation

func Em

func Em(children ...Node) *em

Em creates a new em element Allows optional child nodes to be passed during creation

func Embed

func Embed(children ...Node) *embed

Embed creates a new embed element Allows optional child nodes to be passed during creation

func Fieldset

func Fieldset(children ...Node) *fieldset

Fieldset creates a new fieldset element Allows optional child nodes to be passed during creation

func Figcaption

func Figcaption(children ...Node) *figcaption

Figcaption creates a new figcaption element Allows optional child nodes to be passed during creation

func Figure

func Figure(children ...Node) *figure

Figure creates a new figure element Allows optional child nodes to be passed during creation

func Footer(children ...Node) *footer

Footer creates a new footer element Allows optional child nodes to be passed during creation

func Form

func Form(children ...Node) *form

Form creates a new form element Allows optional child nodes to be passed during creation

func G

func G(children ...Node) *g

G creates a new g element Allows optional child nodes to be passed during creation

func H1

func H1(children ...Node) *h1

H1 creates a new h1 element Allows optional child nodes to be passed during creation

func H2

func H2(children ...Node) *h2

H2 creates a new h2 element Allows optional child nodes to be passed during creation

func H3

func H3(children ...Node) *h3

H3 creates a new h3 element Allows optional child nodes to be passed during creation

func H4

func H4(children ...Node) *h4

H4 creates a new h4 element Allows optional child nodes to be passed during creation

func H5

func H5(children ...Node) *h5

H5 creates a new h5 element Allows optional child nodes to be passed during creation

func H6

func H6(children ...Node) *h6

H6 creates a new h6 element Allows optional child nodes to be passed during creation

func HTML

func HTML(children ...Node) *html_

HTML creates a new html element Allows optional child nodes to be passed during creation

func Head(children ...Node) *head

Head creates a new head element Allows optional child nodes to be passed during creation

func Header(children ...Node) *header

Header creates a new header element Allows optional child nodes to be passed during creation

func Hr

func Hr(children ...Node) *hr

Hr creates a new hr element Allows optional child nodes to be passed during creation

func I

func I(children ...Node) *i

I creates a new i element Allows optional child nodes to be passed during creation

func Iframe

func Iframe(children ...Node) *iframe

Iframe creates a new iframe element Allows optional child nodes to be passed during creation

func Img

func Img(children ...Node) *img

Img creates a new img element Allows optional child nodes to be passed during creation

func Input

func Input(children ...Node) *input

Input creates a new input element Allows optional child nodes to be passed during creation

func Ins

func Ins(children ...Node) *ins

Ins creates a new ins element Allows optional child nodes to be passed during creation

func Kbd

func Kbd(children ...Node) *kbd

Kbd creates a new kbd element Allows optional child nodes to be passed during creation

func Label

func Label(children ...Node) *label

Label creates a new label element Allows optional child nodes to be passed during creation

func Legend

func Legend(children ...Node) *legend

Legend creates a new legend element Allows optional child nodes to be passed during creation

func Li

func Li(children ...Node) *li

Li creates a new li element Allows optional child nodes to be passed during creation

func Line

func Line(children ...Node) *line

Line creates a new line element Allows optional child nodes to be passed during creation

func Link(children ...Node) *link

Link creates a new link element Allows optional child nodes to be passed during creation

func Main

func Main(children ...Node) *main

Main creates a new main element Allows optional child nodes to be passed during creation

func MapEl

func MapEl(children ...Node) *mapEl_

Map creates a new map element Allows optional child nodes to be passed during creation

func Mark

func Mark(children ...Node) *mark

Mark creates a new mark element Allows optional child nodes to be passed during creation

func Meta

func Meta(children ...Node) *meta

Meta creates a new meta element Allows optional child nodes to be passed during creation

func Meter

func Meter(children ...Node) *meter

Meter creates a new meter element Allows optional child nodes to be passed during creation

func Nav(children ...Node) *nav

Nav creates a new nav element Allows optional child nodes to be passed during creation

func Noscript

func Noscript(children ...Node) *noscript

Noscript creates a new noscript element Allows optional child nodes to be passed during creation

func Object

func Object(children ...Node) *object

Object creates a new object element Allows optional child nodes to be passed during creation

func Ol

func Ol(children ...Node) *ol

Ol creates a new ol element Allows optional child nodes to be passed during creation

func Optgroup

func Optgroup(children ...Node) *optgroup

Optgroup creates a new optgroup element Allows optional child nodes to be passed during creation

func Option

func Option(children ...Node) *option

Option creates a new option element Allows optional child nodes to be passed during creation

func Output

func Output(children ...Node) *output

Output creates a new output element Allows optional child nodes to be passed during creation

func P

func P(children ...Node) *p

P creates a new p element Allows optional child nodes to be passed during creation

func Param

func Param(children ...Node) *param

Param creates a new param element Allows optional child nodes to be passed during creation

func Path

func Path(children ...Node) *path

Path creates a new path element Allows optional child nodes to be passed during creation

func Picture

func Picture(children ...Node) *picture

Picture creates a new picture element Allows optional child nodes to be passed during creation

func Polygon

func Polygon(children ...Node) *polygon

Polygon creates a new polygon element Allows optional child nodes to be passed during creation

func Polyline

func Polyline(children ...Node) *polyline

Polyline creates a new polyline element Allows optional child nodes to be passed during creation

func Pre

func Pre(children ...Node) *pre

Pre creates a new pre element Allows optional child nodes to be passed during creation

func Progress

func Progress(children ...Node) *progress

Progress creates a new progress element Allows optional child nodes to be passed during creation

func Q

func Q(children ...Node) *q

Q creates a new q element Allows optional child nodes to be passed during creation

func Rect

func Rect(children ...Node) *rect

Rect creates a new rect element Allows optional child nodes to be passed during creation

func Rp

func Rp(children ...Node) *rp

Rp creates a new rp element Allows optional child nodes to be passed during creation

func Rt

func Rt(children ...Node) *rt

Rt creates a new rt element Allows optional child nodes to be passed during creation

func Ruby

func Ruby(children ...Node) *ruby

Ruby creates a new ruby element Allows optional child nodes to be passed during creation

func S

func S(children ...Node) *s

S creates a new s element Allows optional child nodes to be passed during creation

func SVG

func SVG(children ...Node) *svg

SVG creates a new svg element Allows optional child nodes to be passed during creation

func Samp

func Samp(children ...Node) *samp

Samp creates a new samp element Allows optional child nodes to be passed during creation

func Script

func Script(children ...Node) *script

Script creates a new script element Allows optional child nodes to be passed during creation

func Section

func Section(children ...Node) *section

Section creates a new section element Allows optional child nodes to be passed during creation

func Select

func Select(children ...Node) *select_

Select creates a new select element Allows optional child nodes to be passed during creation

func Small

func Small(children ...Node) *small

Small creates a new small element Allows optional child nodes to be passed during creation

func Source

func Source(children ...Node) *source

Source creates a new source element Allows optional child nodes to be passed during creation

func Span

func Span(children ...Node) *span

Span creates a new span element Allows optional child nodes to be passed during creation

func Strong

func Strong(children ...Node) *strong

Strong creates a new strong element Allows optional child nodes to be passed during creation

func Style

func Style(children ...Node) *style

Style creates a new style element Allows optional child nodes to be passed during creation

func Sub

func Sub(children ...Node) *sub

Sub creates a new sub element Allows optional child nodes to be passed during creation

func Summary

func Summary(children ...Node) *summary

Summary creates a new summary element Allows optional child nodes to be passed during creation

func Sup

func Sup(children ...Node) *sup

Sup creates a new sup element Allows optional child nodes to be passed during creation

func Table

func Table(children ...Node) *table

Table creates a new table element Allows optional child nodes to be passed during creation

func Tbody

func Tbody(children ...Node) *tbody

Tbody creates a new tbody element Allows optional child nodes to be passed during creation

func Td

func Td(children ...Node) *td

Td creates a new td element Allows optional child nodes to be passed during creation

func Template

func Template(children ...Node) *template

Template creates a new template element Allows optional child nodes to be passed during creation

func Textarea

func Textarea(children ...Node) *textarea

Textarea creates a new textarea element Allows optional child nodes to be passed during creation

func Tfoot

func Tfoot(children ...Node) *tfoot

Tfoot creates a new tfoot element Allows optional child nodes to be passed during creation

func Th

func Th(children ...Node) *th

Th creates a new th element Allows optional child nodes to be passed during creation

func Thead

func Thead(children ...Node) *thead

Thead creates a new thead element Allows optional child nodes to be passed during creation

func Time

func Time(children ...Node) *time

Time creates a new time element Allows optional child nodes to be passed during creation

func Title

func Title(children ...Node) *title

Title creates a new title element Allows optional child nodes to be passed during creation

func Tr

func Tr(children ...Node) *tr

Tr creates a new tr element Allows optional child nodes to be passed during creation

func Track

func Track(children ...Node) *track

Track creates a new track element Allows optional child nodes to be passed during creation

func U

func U(children ...Node) *u

U creates a new u element Allows optional child nodes to be passed during creation

func Ul

func Ul(children ...Node) *ul

Ul creates a new ul element Allows optional child nodes to be passed during creation

func Use

func Use(children ...Node) *use

Use creates a new use element Allows optional child nodes to be passed during creation

func Var

func Var(children ...Node) *var_

Var creates a new var element Allows optional child nodes to be passed during creation

func Video

func Video(children ...Node) *video

Video creates a new video element Allows optional child nodes to be passed during creation

func Wbr

func Wbr(children ...Node) *wbr

Wbr creates a new wbr element Allows optional child nodes to be passed during creation

Types

type Attribute

type Attribute map[string]string

Attribute represents HTML element attributes

type Node

type Node interface {
	Render(w io.Writer) error
}

Node interface defines components that can render themselves

func Group

func Group(children ...Node) Node

Group combines multiple nodes without a wrapper element

func If

func If(condition bool, then Node) Node

If conditionally renders content when condition is true

func IfElse

func IfElse(condition bool, then Node, else_ Node) Node

IfElse conditionally renders one of two nodes based on condition

func IfElseFunc

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

IfElseFunc conditionally renders content when condition is true Uses a callback function to avoid evaluating the content when condition is false

func IfFunc

func IfFunc(condition bool, thenFn func() Node) Node

IfFunc conditionally renders content when condition is true Uses a callback function to avoid evaluating the content when condition is false

func Map

func Map[T any](items []T, transform func(item T) Node) Node

Map renders a collection of items using a transform function

func Raw

func Raw(content string) Node

Raw creates a node that renders raw HTML content

func Rawf

func Rawf(format string, args ...any) Node

Rawf creates a node that renders formatted raw HTML content

func Text

func Text(content string) Node

Text creates a node that renders HTML-escaped text content

func Textf

func Textf(format string, args ...any) Node

Textf creates a node that renders formatted HTML-escaped text

type Tag

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

Tag represents the base structure for all HTML elements

func NewTag

func NewTag(name string, isVoid bool, children []Node) *Tag

NewTag creates a new Tag instance with specified properties

func (*Tag) Attribute

func (t *Tag) Attribute(key, value string) *Tag

Attribute adds or updates an attribute for the tag Allows method chaining for fluent interface

func (*Tag) Children

func (e *Tag) Children(children ...Node) *Tag

Children set the children for a given tag.

func (*Tag) Render

func (e *Tag) Render(w io.Writer) error

Render implements Node.

Jump to

Keyboard shortcuts

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