Skip to content

FrenchSoftware/libhtml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord

libhtml

A simple Go library to write HTML in plain Go

Installation

go get github.com/frenchsoftware/libhtml

Example

package main

import (
	"fmt"
	"github.com/frenchsoftware/libhtml/attr"
	"github.com/frenchsoftware/libhtml/html"
)

func main() {
	page := html.Html(
		attr.Lang("en"),
		html.Head(
			html.Title(html.Text("Hello, World!")),
			html.Meta(attr.Charset("utf-8")),
		),
		html.Body(
			html.H1(html.Text("Welcome")),
			html.P(html.Text("This is a simple example.")),
		),
	)

	fmt.Println(html.String(page))
}

Output:

<html lang="en"><head><title>Hello, World!</title><meta charset="utf-8"></head><body><h1>Welcome</h1><p>This is a simple example.</p></body></html>

License

MIT License

About

A simple Go library to write HTML in plain Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages