html

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 3 Imported by: 0

README

Html

A highly opinionated code driven HTML generator.

Usage:

    page := []HtmlElement{
		DocType(),
		Html(Lang("en")).AddElements(
			Head().AddElements(
				Meta(Key("charset", "utf-8")),
				Title().AddElements(Content("Page Title")),
				Style().AddElements(Content(
					"ul.samples {list-style: none; margin: 0; padding: 0;" +
					" margin-block-start: 1px; margin-block-end: 1px;}\n" +
					"ul.samples li {display: inline-block; width: 300px;}\n" +
					"ul.samples li.good {background-color: #008000;}\n")),
			),
			Body().AddElements(
				Heading(Level(1)).AddElements(Content("The Title of the Page")),
				P().AddElements(Content("This is the first sentence."))),
			Ul().AddElements(
				Li().AddElements(
					Img(Src("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA7UlEQVR4"+
						"nGJiwAMGXJJZUFCwrmO95LL/3+tBfBaYhByblY1AMIj1ZHLg54sHQSxGqJzBPn4o61/SV4Zn728imyh4+"+
						"y8IHNv2/SMWywPmZP/9e5abQXsWNqfxMcz6G4XLtZ8YPjKkMOL0Fve+v244JRmUPz5ckINTNvDD37/lErhkdX"+
						"f9/TtNGpesQOyfv7txW/zz708HKJMFVUYvxJSF4dpBbJrUpzz9+/fvr21YpCSK7oKC96QfppS401VwyAdiBpL"+
						"ganCsHA7gwJAyX/MIJPWllRtVHOzawEAGhuub//Z8wO1BTEB+0gQEAAD//3QpXYUSeN4MAAAAAElFTkSuQmCC")),
				),
			),
		),
	}

	output := ""
	for _, el := range page {
		output += el.Render()
	}

HTML5 elements are currently supported although they are mostly only at the bare minumum.

Notes: This is not optimized yet, first we'll work on correctness, then once it's fairly stable then working on making it faster will happen.

All valid html5 tags want to be implemented, but for now it's driven by the ones currently in use.

TODO:

  • Add Validation
  • Add Variables & Conditionals
  • Optimize
  • Test
  • Add CSS

HTML Tags

<!DOCTYPE>
<a>
<abbr>
<address>
<area>
<article>
<aside>
<audio>
<b>
<base>
<bdi>
<bdo>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<cite>
<code>
<col>
<colgroup>
<data>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<footer>
<form>
<h1> - <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<meta>
<meter>
<nav>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<picture>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strong>
<style>
<sub>
<summary>
<sup>
<svg>
<table>
<tbody>
<td>
<template>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<u>
<ul>
<var>
<video>
<wbr>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessKey

func AccessKey(accesskey string) func(e Element)

func Action

func Action(t string) func(Element)

Action - form

func Charset

func Charset(charset string) func(Element)

Charset - for meta

func Class

func Class(class string) func(e Element)

func ContentAttr

func ContentAttr(t string) func(Element)

ContentAttr - meta

func Coords

func Coords(coords string) func(Element)

Coords - for area

func Dir

func Dir(dir string) func(Element)

Dir - bdo

func EncType

func EncType(t string) func(Element)

EncType - form application/x-www-form-urlencoded multipart/form-data text/plain

func FormId

func FormId(formid string) func(Element)

FormId - meter

func Hidden

func Hidden(hidden string) func(e Element)

func High

func High(high string) func(Element)

High - meter

func Href

func Href(href string) func(Element)

Href - for image

func Id

func Id(id string) func(element Element)

func Kind

func Kind(dir string) func(Element)

Kind - track

func LabelAttr

func LabelAttr(dir string) func(Element)

LabelAttr - track

func Lang

func Lang(lang string) func(element Element)

func Level

func Level(level int) func(*tag)

func Low

func Low(low string) func(Element)

Low - meter

func Max

func Max(max string) func(Element)

Max - meter

func Media

func Media(media string) func(Element)

Media - for source

func Method

func Method(t string) func(Element)

Method - form

func Min

func Min(min string) func(Element)

Min - meter

func Name

func Name(name string) func(Element)

Name - Attribute for form

func Optimum

func Optimum(optimum string) func(Element)

Optimum - meter

func Rel

func Rel(dir string) func(Element)

Rel - bdo

func Shape

func Shape(shape string) func(Element)

Shape - for area

func Src

func Src(source string) func(Element)

Src - for image

func SrcLang

func SrcLang(dir string) func(Element)

SrcLang - track

func SrcSet

func SrcSet(srcset string) func(Element)

SrcSet - for Source

func StyleAttr

func StyleAttr(t string) func(Element)

StyleAttr - all

func TabIndex

func TabIndex(t string) func(Element)

TabIndex - meta

func Target

func Target(target string) func(Element)

Target - Attribute for form, a, base

func TitleAttr

func TitleAttr(title string) func(element Element)

func Type

func Type(t string) func(Element)

Type - script/style

func UseMap

func UseMap(usemap string) func(Element)

UseMap - for image

func Value

func Value(value string) func(Element)

Value - meter

Types

type Element

type Element interface {
	Render(w io.Writer) (n int, err error)
	AddElements(elements ...Element) Element
	AddAttribute(key string, val string)
}

func Abbr

func Abbr(attrs ...func(Element)) Element

func Address

func Address(attrs ...func(Element)) Element

func Area

func Area(attrs ...func(Element)) Element

func Article

func Article(attrs ...func(Element)) Element

func Aside

func Aside(attrs ...func(Element)) Element

func Audio

func Audio(attrs ...func(Element)) Element

func B

func B(attrs ...func(Element)) Element

func Base

func Base(attrs ...func(Element)) Element

func Bdi

func Bdi(attrs ...func(Element)) Element

func Bdo

func Bdo(attrs ...func(Element)) Element

func Blockquote

func Blockquote(attrs ...func(Element)) Element

func Body

func Body(attrs ...func(Element)) Element

func Br

func Br(attrs ...func(Element)) Element

func Button

func Button(attrs ...func(Element)) Element

func Canvas

func Canvas(attrs ...func(Element)) Element

func Caption

func Caption(attrs ...func(Element)) Element

func Cite

func Cite(attrs ...func(Element)) Element

func Code

func Code(attrs ...func(Element)) Element

func Col

func Col(attrs ...func(Element)) Element

func Colgroup

func Colgroup(attrs ...func(Element)) Element

func Content

func Content(data string) Element

Content adds raw content to the stream.

func Data

func Data(attrs ...func(Element)) Element

func DataList

func DataList(attrs ...func(Element)) Element

func Dd

func Dd(attrs ...func(Element)) Element

func Del

func Del(attrs ...func(Element)) Element

func Details

func Details(attrs ...func(Element)) Element

func Dfn

func Dfn(attrs ...func(Element)) Element

func Dialog

func Dialog(attrs ...func(Element)) Element

func Div

func Div(attrs ...func(Element)) Element

func Dl

func Dl(attrs ...func(Element)) Element

func DocType

func DocType() Element

func Dt

func Dt(attrs ...func(Element)) Element

func Em

func Em(attrs ...func(Element)) Element

func Embed

func Embed(attrs ...func(Element)) Element

func Fieldset

func Fieldset(attrs ...func(Element)) Element

func FigCaption

func FigCaption(attrs ...func(Element)) Element

func Figure

func Figure(attrs ...func(Element)) Element
func Footer(attrs ...func(Element)) Element

func Form

func Form(attrs ...func(Element)) Element
func Head(attrs ...func(Element)) Element
func Header(attrs ...func(Element)) Element

func Heading

func Heading(attrs ...func(*tag)) Element

func Hr

func Hr(attrs ...func(Element)) Element

func Html

func Html(attrs ...func(Element)) Element

func I

func I(attrs ...func(Element)) Element

func Img

func Img(attrs ...func(Element)) Element

func Input

func Input(attrs ...func(Element)) Element

func Ins

func Ins(attrs ...func(Element)) Element

func Kbd

func Kbd(attrs ...func(Element)) Element

func Label

func Label(attrs ...func(Element)) Element

func Legend

func Legend(attrs ...func(Element)) Element

func Li

func Li(attrs ...func(Element)) Element
func Link(attrs ...func(Element)) Element

func Main

func Main(attrs ...func(Element)) Element

func Map

func Map(attrs ...func(Element)) Element

func Mark

func Mark(attrs ...func(Element)) Element

func Meta

func Meta(attrs ...func(Element)) Element

func Meter

func Meter(attrs ...func(Element)) Element
func Nav(attrs ...func(Element)) Element

func NoScript

func NoScript(attrs ...func(Element)) Element

func Object

func Object(attrs ...func(Element)) Element

func Ol

func Ol(attrs ...func(Element)) Element

func OptGroup

func OptGroup(attrs ...func(Element)) Element

func Option

func Option(attrs ...func(Element)) Element

func Output

func Output(attrs ...func(Element)) Element

func P

func P(attrs ...func(Element)) Element

func Param

func Param(attrs ...func(Element)) Element

func Picture

func Picture(attrs ...func(Element)) Element

func Pre

func Pre(attrs ...func(Element)) Element

func Progress

func Progress(attrs ...func(Element)) Element

func Q

func Q(attrs ...func(Element)) Element

func Rp

func Rp(attrs ...func(Element)) Element

func Rt

func Rt(attrs ...func(Element)) Element

func Ruby

func Ruby(attrs ...func(Element)) Element

func S

func S(attrs ...func(Element)) Element

func Samp

func Samp(attrs ...func(Element)) Element

func Script

func Script(attrs ...func(Element)) Element

func Section

func Section(attrs ...func(Element)) Element

func Select

func Select(attrs ...func(Element)) Element

func Small

func Small(attrs ...func(Element)) Element

func Source

func Source(attrs ...func(Element)) Element

func Span

func Span(attrs ...func(Element)) Element

func Strong

func Strong(attrs ...func(Element)) Element

func Style

func Style(attrs ...func(Element)) Element

func Sub

func Sub(attrs ...func(Element)) Element

func Summary

func Summary(attrs ...func(Element)) Element

func Sup

func Sup(attrs ...func(Element)) Element

func Svg

func Svg(attrs ...func(Element)) Element

func Table

func Table(attrs ...func(Element)) Element

func Tbody

func Tbody(attrs ...func(Element)) Element

func Td

func Td(attrs ...func(Element)) Element

func Template

func Template(attrs ...func(Element)) Element

func TextArea

func TextArea(attrs ...func(Element)) Element

func Tfoot

func Tfoot(attrs ...func(Element)) Element

func Th

func Th(attrs ...func(Element)) Element

func Thead

func Thead(attrs ...func(Element)) Element

func Time

func Time(attrs ...func(Element)) Element

func Title

func Title(attrs ...func(Element)) Element

func Tr

func Tr(attrs ...func(Element)) Element

func Track

func Track(attrs ...func(Element)) Element

func U

func U(attrs ...func(Element)) Element

func Ul

func Ul(attrs ...func(Element)) Element

func Var

func Var(attrs ...func(Element)) Element

func Video

func Video(attrs ...func(Element)) Element

func Wbr

func Wbr(attrs ...func(Element)) Element

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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