html

package
v0.0.0-...-576eb72 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2014 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package html provides some basic data structures for declaring HTML elements using Go code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(s string) string

func Minify

func Minify(w io.Writer, r io.Reader) error

Minify removes insignificant whitespace from the given HTML. Please, keep in mind that this function could break your HTML if you're using embedded scripts or if you rely on automatical semicolon insertion, because multiple whitespaces (' ', '\n', '\t' and '\r') will be collapsed into a single ' ' character. Formatting inside pre and textarea tags is preserved.

func Unescape

func Unescape(s string) string

Types

type Attrs

type Attrs map[string]string

func (Attrs) Add

func (a Attrs) Add(key, value string)

func (Attrs) Equal

func (a Attrs) Equal(b Attrs) bool

Equal returns true iff both a and b have the same attributes. Note that attributes are tested using case sensitive comparison.

func (Attrs) Remove

func (a Attrs) Remove(key, value string)

func (Attrs) WriteTo

func (a Attrs) WriteTo(w io.Writer) (int, error)

type Node

type Node struct {
	Type     Type
	Tag      string
	Attrs    Attrs
	Content  string
	Next     *Node
	Children *Node
	Open     bool
}

func A

func A(href, text string) *Node

func Abbr

func Abbr(title, text string) *Node

func Article

func Article(children ...*Node) *Node

func Aside

func Aside(children ...*Node) *Node

func B

func B(text string) *Node

func Blockquote

func Blockquote(text string) *Node

func Br

func Br() *Node

func Button

func Button(text string) *Node

func Caption

func Caption(text string) *Node

func Div

func Div(children ...*Node) *Node

func Em

func Em(text string) *Node

func P

func P(children ...*Node) *Node

func Small

func Small(text string) *Node

func Span

func Span(children ...*Node) *Node

func Text

func Text(text string) *Node

func (*Node) AddAttr

func (n *Node) AddAttr(name string, value interface{}) *Node

func (*Node) AddClass

func (n *Node) AddClass(cls string) *Node

func (*Node) Append

func (n *Node) Append(node *Node) *Node

func (*Node) AppendChild

func (n *Node) AppendChild(c *Node)

func (*Node) AppendTo

func (n *Node) AppendTo(node *Node) *Node

func (*Node) Attr

func (n *Node) Attr(name string) string

func (*Node) Copy

func (n *Node) Copy() *Node

Copy returns a deep copy of the node.

func (*Node) DelAttr

func (n *Node) DelAttr(name string) *Node

func (*Node) Disable

func (n *Node) Disable(name string) *Node

func (*Node) Enable

func (n *Node) Enable(name string) *Node

func (*Node) Find

func (n *Node) Find(typ Type, tag string, attrs Attrs) *Node

Find returns the first Node (including the receiver) which matches the provided query parameters. A Node matches if all the following conditions are true.

typ == TypeAny || n.Type == typ
tag == "" || n.Tag == tag (case insensitive)
attrs == nil || attrs.Equal(n.Attrs)

The nodes are iterated following the Next node and then the first Children Node.

func (*Node) HTML

func (n *Node) HTML() template.HTML

func (*Node) LastChild

func (n *Node) LastChild() *Node

func (*Node) NChildren

func (n *Node) NChildren() int

func (*Node) Prepend

func (n *Node) Prepend(node *Node) *Node

func (*Node) PrependTo

func (n *Node) PrependTo(node *Node) *Node

func (*Node) RemoveAttr

func (n *Node) RemoveAttr(name string, value interface{}) *Node

func (*Node) RemoveClass

func (n *Node) RemoveClass(cls string) *Node

func (*Node) Render

func (n *Node) Render(buf *bytes.Buffer)

func (*Node) SetAttr

func (n *Node) SetAttr(name string, value interface{}) *Node

func (*Node) String

func (n *Node) String() string

func (*Node) WriteTo

func (n *Node) WriteTo(w io.Writer) (int, error)

type Type

type Type int
const (
	TypeTag Type = iota
	TypeText
	TypeAny Type = -1
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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