hf

package module
v0.0.0-...-d3f1c95 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

go-html-frame

HTML framework for Go web.

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// HTML Character Entity copyright
	COPY = HTMLNode("©")
	// HTML Character Entity ampersand
	AMP = HTMLNode("&")
	// HTML Character Entity less than
	LT = HTMLNode("<")
	// HTML Character Entity greater than
	GT = HTMLNode(">")
	// HTML Character Entity cent
	CENT = HTMLNode("¢")
	// HTML Character Entity pound
	POUND = HTMLNode("£")
	// HTML Character Entity yen
	YEN = HTMLNode("¥")
	// HTML Character Entity euro
	EURO = HTMLNode("€")
	// HTML Character Entity registered trademark
	REG = HTMLNode("®")
	// HTML Character Entity non-breaking space
	NBSP  = HTMLNode(" ")
	TIMES = HTMLNode("×")
	LAQUO = HTMLNode("«")
	RAQUO = HTMLNode("»")
)

HTML Entities

View Source
var Default = RenderOptions{}

Functions

func Script

func Script(format string, args ...interface{}) template.HTML

func Url

func Url(format string, args ...interface{}) string

Types

type Element

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

func A

func A(href string, children ...Node) *Element

func B

func B(children ...Node) *Element

func BODY

func BODY() *Element

func BUTTON

func BUTTON(children ...Node) *Element

func CAPTION

func CAPTION(children ...Node) *Element

The caption element

func COLGROUP

func COLGROUP(span int, cols ...*Void) *Element

The colgroup element

If span > 0, cols are ignored. Otherwise, cols (col tags) are appended as children.

func DD

func DD(children ...Node) *Element

func DIV

func DIV(children ...Node) *Element

func DL

func DL(children ...Node) *Element

func DT

func DT(children ...Node) *Element
func FOOTER(children ...Node) *Element

func FORM

func FORM(method, action string, children ...Node) *Element

func H1

func H1(children ...Node) *Element

func H2

func H2(children ...Node) *Element

func H3

func H3(children ...Node) *Element

func H4

func H4(children ...Node) *Element

func H5

func H5(children ...Node) *Element

func H6

func H6(children ...Node) *Element
func HEAD() *Element

func LABEL

func LABEL(For string, children ...Node) *Element

func LI

func LI(children ...Node) *Element

func MAP

func MAP(name string, children ...Node) *Element

The map element.

Example
h := HTML("")
body := h.Body()
body.Child(MAP("menu", AREA("fun.html", "Fun", "circle", []int{1, 2, 3, 4})))
fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output:

<!DOCTYPE html>
<meta charset="utf-8"><map name="menu"><area alt="Fun" coords="12,3,4," href="fun.html" shape="circle"></map>
func NAV(children ...Node) *Element

func NOSCRIPT

func NOSCRIPT(children ...Node) *Element

func OBJECT

func OBJECT(children ...Node) *Element

func OL

func OL(children ...Node) *Element

func OPTGROUP

func OPTGROUP(label string, children ...*Element) *Element

func OPTION

func OPTION(value, text string) *Element

func P

func P(children ...Node) *Element

func PRE

func PRE(children ...Node) *Element

func RB

func RB(children ...Node) *Element

func RP

func RP(children ...Node) *Element

func RT

func RT(children ...Node) *Element

func RTC

func RTC(children ...Node) *Element

func RUBY

func RUBY(children ...Node) *Element

func SCRIPT

func SCRIPT(src string, content string) *Element

func SELECT

func SELECT(children ...*Element) *Element

func SMALL

func SMALL(children ...Node) *Element

func SPAN

func SPAN(children ...Node) *Element

func TABLE

func TABLE(children ...*Element) *Element

The table element

Example
h := HTML("")
body := h.Body()
body.Child(TABLE(
	CAPTION(T("Hello")),
	COLGROUP(0,
		COL(2), COL(1),
	),
	COLGROUP(5),
	THEAD(
		TR(TH()),
	),
	TBODY(
		TR(TD()),
	),
	TFOOT(),
))
fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output:

<!DOCTYPE html>
<meta charset="utf-8"><table><caption>Hello</caption><col span="2"><col><colgroup span="5"><thead><tr><th><tbody><tr><td><tfoot></table>

func TBODY

func TBODY(trs ...*Element) *Element

The tbody element.

func TD

func TD(children ...Node) *Element

The td element.

func TEXTAREA

func TEXTAREA(name, value string, children ...Node) *Element

func TFOOT

func TFOOT(trs ...*Element) *Element

The tfoot element.

func TH

func TH(children ...Node) *Element

The th element.

func THEAD

func THEAD(trs ...*Element) *Element

The thead element.

func TITLE

func TITLE(title string) *Element

func TR

func TR(children ...*Element) *Element

func UL

func UL(children ...Node) *Element

func (*Element) Attr

func (e *Element) Attr(name string, value string) *Element

func (*Element) Child

func (e *Element) Child(el ...Node) *Element

func (*Element) ChildEls

func (e *Element) ChildEls(els ...*Element) *Element

func (*Element) ChildVoids

func (e *Element) ChildVoids(vs ...*Void) *Element

func (*Element) Children

func (t *Element) Children() []Element

func (*Element) NonEmptyAttr

func (e *Element) NonEmptyAttr(name string, value string) *Element

func (*Element) T

func (e *Element) T(txt string) *Element

func (*Element) WriteTo

func (e *Element) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)

type HTMLNode

type HTMLNode string

Text

func NodeToHTMLBytes

func NodeToHTMLBytes(el Node, opt RenderOptions) HTMLNode

func NumEnt

func NumEnt(num int) HTMLNode

NumEnt returns HTMLBytes a numerical entity.

func T

func T(text string) HTMLNode

func Tf

func Tf(format string, args ...interface{}) HTMLNode

func (HTMLNode) Type

func (h HTMLNode) Type() TagType

func (HTMLNode) WriteRaw

func (h HTMLNode) WriteRaw(b Writer)

func (HTMLNode) WriteTo

func (h HTMLNode) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)

type HTMLNodeSet

type HTMLNodeSet []HTMLNode

func (*HTMLNodeSet) Del

func (set *HTMLNodeSet) Del(s HTMLNode)

func (*HTMLNodeSet) Put

func (set *HTMLNodeSet) Put(s HTMLNode)

type Html

type Html struct {
	Element
}
Example
h := HTML("")
fmt.Println(NodeToHTMLBytes(h, RenderOptions{DisableOmit: true, SortAttr: true}))
Output:

<!DOCTYPE html>
<html><head><meta charset="utf-8"></head><body></body></html>

func HTML

func HTML(lang string) Html

func (Html) Body

func (h Html) Body() *Element

func (Html) Css

func (h Html) Css(href string) Html

func (Html) Favicon

func (h Html) Favicon(href, tp string) Html

func (Html) Head

func (h Html) Head() *Element

func (Html) Lang

func (h Html) Lang(lang string) Html

func (Html) SCRIPT

func (h Html) SCRIPT(src string, content string) Html

func (Html) Title

func (h Html) Title(title string) Html

func (Html) Type

func (h Html) Type() TagType

Implementation of Node interface

func (Html) WriteTo

func (h Html) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)

Implementation of Node interface

type Node

type Node interface {
	Type() TagType
	WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)
}

type RenderOptions

type RenderOptions struct {
	Ident       HTMLNode
	DisableOmit bool
	// Sort attributes names before export.
	// This is useful for testing because otherwise the exported attributes could be random.
	SortAttr bool
}

type Void

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

An HTML void element

func AREA

func AREA(href, alt string, shape string, coords []int) *Void

The area element

func BASE

func BASE(href, target string) *Void

The base element

Example
h := HTML("")
head := h.Head()
head.Child(BASE("/images", "_blank"))
fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output:

<!DOCTYPE html>
<meta charset="utf-8"><base href="/images" target="_blank">

func BR

func BR() *Void

The br element

func COL

func COL(span int) *Void

The col element. span is the number of columns spanned by the element.

func EMBED

func EMBED(src URL, tp string, width, height int) *Void

The embed element.

tp is the type attribute. Empty string will be ignored. width or height with a negative value will be ignored.

Example
h := HTML("")
h.Body().Child(
	EMBED(URL("http://example.com/a.swf"), "flash", 100, 200),
	EMBED(URL("http://example.com/a.swf"), "", -1, -1),
)
fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output:

<!DOCTYPE html>
<meta charset="utf-8"><embed height="200" src="http://example.com/a.swf" type="flash" width="100"><embed src="http://example.com/a.swf">

func HR

func HR() *Void

The br element

Example
h := HTML("")
h.Body().Child(HR())
fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output:

<!DOCTYPE html>
<meta charset="utf-8"><hr>

func IMG

func IMG(src URL, alt string) *Void

func INPUT

func INPUT(tp, name, value string) *Void
func LINK(href, rel string) *Void

func META

func META() *Void

func PARAM

func PARAM(name, value string) *Void

func (*Void) AddClass

func (v *Void) AddClass(classes ...string) *Void

func (*Void) Attr

func (v *Void) Attr(name string, value string) *Void

func (*Void) AttrIfNotEmpty

func (v *Void) AttrIfNotEmpty(name, value string) *Void

func (*Void) DelClass

func (v *Void) DelClass(classes ...string) *Void

func (*Void) ID

func (t *Void) ID(id string) *Void

func (*Void) Name

func (v *Void) Name() HTMLNode

func (*Void) NonEmptyAttr

func (v *Void) NonEmptyAttr(name, value string) *Void

func (*Void) TabIndex

func (v *Void) TabIndex(tablInex int)

func (*Void) Title

func (v *Void) Title(title string)

func (*Void) Type

func (v *Void) Type() TagType

func (*Void) WriteTo

func (v *Void) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)

Implementation of Node.WriteTo. This will be called to generate open tags of both void and normal elements

type Writer

type Writer interface {
	io.ByteWriter
	io.Writer
	WriteString(string) (int, error)
}

Directories

Path Synopsis
Package htmldef provides some constants definition for hf package.
Package htmldef provides some constants definition for hf package.

Jump to

Keyboard shortcuts

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