go.h: github.com/daaku/go.h Index | Files

package h

import "github.com/daaku/go.h"

Package provides a psuedo-DOM style approach to generating HTML markup. **Unstable API. Work in progress.**

Index

Package Files

attributes.go document.go frag.go h.go helper_hidden_inputs.go helper_link_style.go node.go reflect_node.go string.go tags.go unsafe.go unsafe_bytes.go

Constants

const (
    Post = "post"
    Get  = "get"
)

func Render

func Render(h HTML) (string, error)

Render HTML as a string.

func Write

func Write(w io.Writer, h HTML) (int, error)

Write HTML into a writer.

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, html HTML)

Writes a HTML response and writes errors on failure.

type A

type A struct {
    ID     string                 `h:"attr"`
    Class  string                 `h:"attr"`
    Style  string                 `h:"attr"`
    Title  string                 `h:"attr"`
    HREF   string                 `h:"attr"`
    Target string                 `h:"attr"`
    Rel    string                 `h:"attr"`
    Inner  HTML                   `h:"inner"`
    Data   map[string]interface{} `h:"dict"`
}

func (*A) HTML

func (a *A) HTML() (HTML, error)

type Attributes

type Attributes map[string]interface{}

func (Attributes) Write

func (attrs Attributes) Write(w io.Writer, prefix string) (int, error)

Render attributes with using the optional key prefix.

type Body

type Body struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Body) HTML

func (b *Body) HTML() (HTML, error)

type Button

type Button struct {
    ID    string                 `h:"attr"`
    Class string                 `h:"attr"`
    Type  string                 `h:"attr"`
    Style string                 `h:"attr"`
    Title string                 `h:"attr"`
    Data  map[string]interface{} `h:"dict"`
    Inner HTML                   `h:"inner"`
}

func (*Button) HTML

func (b *Button) HTML() (HTML, error)

type Div

type Div struct {
    ID    string                 `h:"attr"`
    Class string                 `h:"attr"`
    Style string                 `h:"attr"`
    Data  map[string]interface{} `h:"dict"`
    Inner HTML                   `h:"inner"`
}

func (*Div) HTML

func (d *Div) HTML() (HTML, error)

type Document

type Document struct {
    XMLNS XMLNS
    Inner HTML
}

func (*Document) HTML

func (d *Document) HTML() (HTML, error)

type Form

type Form struct {
    ID     string `h:"attr"`
    Class  string `h:"attr"`
    Style  string `h:"attr"`
    Action string `h:"attr"`
    Method string `h:"attr"`
    Target string `h:"attr"`
    Title  string `h:"attr"`
    Inner  HTML   `h:"inner"`
}

func (*Form) HTML

func (f *Form) HTML() (HTML, error)

type Frag

type Frag []HTML

func (*Frag) Append

func (f *Frag) Append(h HTML)

func (*Frag) HTML

func (f *Frag) HTML() (HTML, error)

func (*Frag) Write

func (f *Frag) Write(w io.Writer) (int, error)

type H1

type H1 struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*H1) HTML

func (h *H1) HTML() (HTML, error)

type H2

type H2 struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*H2) HTML

func (h *H2) HTML() (HTML, error)

type HTML

type HTML interface {
    HTML() (HTML, error)
}

func Compile

func Compile(h HTML) HTML

Compile static HTML into HTML. Will panic if there are errors.

func HiddenInputs

func HiddenInputs(values url.Values) HTML
type Head struct {
    Inner HTML `h:"inner"`
}

func (*Head) HTML

func (h *Head) HTML() (HTML, error)

type I

type I struct {
    ID    string                 `h:"attr"`
    Class string                 `h:"attr"`
    Style string                 `h:"attr"`
    Inner HTML                   `h:"inner"`
    Data  map[string]interface{} `h:"dict"`
}

func (*I) HTML

func (i *I) HTML() (HTML, error)

type Iframe

type Iframe struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Src   string `h:"attr"`
}

func (*Iframe) HTML

func (t *Iframe) HTML() (HTML, error)

type Img

type Img struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Src   string `h:"attr"`
    Alt   string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Img) HTML

func (t *Img) HTML() (HTML, error)

type Input

type Input struct {
    ID          string                 `h:"attr"`
    Class       string                 `h:"attr"`
    Name        string                 `h:"attr"`
    Style       string                 `h:"attr"`
    Type        string                 `h:"attr"`
    Value       string                 `h:"attr"`
    Placeholder string                 `h:"attr"`
    Checked     bool                   `h:"attr"`
    Data        map[string]interface{} `h:"dict"`
    Inner       HTML                   `h:"inner"`
}

func (*Input) HTML

func (i *Input) HTML() (HTML, error)

type Label

type Label struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    For   string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Label) HTML

func (l *Label) HTML() (HTML, error)

type Li

type Li struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Li) HTML

func (l *Li) HTML() (HTML, error)
type Link struct {
    HREF string `h:"attr"`
    Type string `h:"attr"`
    Rel  string `h:"attr"`
}

func (*Link) HTML

func (l *Link) HTML() (HTML, error)

type LinkStyle

type LinkStyle struct {
    HREF string
}

func (*LinkStyle) HTML

func (l *LinkStyle) HTML() (HTML, error)

type Meta

type Meta struct {
    Charset  string `h:"attr"`
    Name     string `h:"attr"`
    Property string `h:"attr"`
    Content  string `h:"attr"`
}

func (*Meta) HTML

func (m *Meta) HTML() (HTML, error)

type Node

type Node struct {
    Tag         string
    Attributes  Attributes
    Inner       HTML
    SelfClosing bool
}

func (*Node) HTML

func (n *Node) HTML() (HTML, error)

func (*Node) Write

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

Write the generated markup for a Node.

type Option

type Option struct {
    ID       string                 `h:"attr"`
    Class    string                 `h:"attr"`
    Style    string                 `h:"attr"`
    Title    string                 `h:"attr"`
    Value    string                 `h:"attr"`
    Selected bool                   `h:"attr"`
    Data     map[string]interface{} `h:"dict"`
    Inner    HTML                   `h:"inner"`
}

func (*Option) HTML

func (o *Option) HTML() (HTML, error)

type P

type P struct {
    ID    string                 `h:"attr"`
    Class string                 `h:"attr"`
    Style string                 `h:"attr"`
    Data  map[string]interface{} `h:"dict"`
    Inner HTML                   `h:"inner"`
}

func (*P) HTML

func (p *P) HTML() (HTML, error)

type Pre

type Pre struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Pre) HTML

func (d *Pre) HTML() (HTML, error)

type Primitive

type Primitive interface {
    Write(io.Writer) (int, error)
}

type ReflectNode

type ReflectNode struct {
    Tag         string
    Node        interface{}
    SelfClosing bool
}

func (*ReflectNode) HTML

func (n *ReflectNode) HTML() (HTML, error)

func (*ReflectNode) Write

func (n *ReflectNode) Write(w io.Writer) (int, error)

Write the generated markup for a ReflectNode.

type Script

type Script struct {
    Src   string `h:"attr"`
    Async bool   `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Script) HTML

func (s *Script) HTML() (HTML, error)

type Select

type Select struct {
    ID       string `h:"attr"`
    Class    string `h:"attr"`
    Name     string `h:"attr"`
    Style    string `h:"attr"`
    Title    string `h:"attr"`
    Multiple bool   `h:"attr"`
    Size     int    `h:"size"`
    Inner    HTML   `h:"inner"`
}

func (*Select) HTML

func (s *Select) HTML() (HTML, error)

type Span

type Span struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Span) HTML

func (s *Span) HTML() (HTML, error)

type String

type String string

func (String) HTML

func (s String) HTML() (HTML, error)

type Strong

type Strong struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Strong) HTML

func (s *Strong) HTML() (HTML, error)

type Table

type Table struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Table) HTML

func (t *Table) HTML() (HTML, error)

type Tbody

type Tbody struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Tbody) HTML

func (t *Tbody) HTML() (HTML, error)

type Td

type Td struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Td) HTML

func (t *Td) HTML() (HTML, error)

type Textarea

type Textarea struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Name  string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Textarea) HTML

func (t *Textarea) HTML() (HTML, error)

type Th

type Th struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Th) HTML

func (t *Th) HTML() (HTML, error)

type Thead

type Thead struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Thead) HTML

func (t *Thead) HTML() (HTML, error)

type Title

type Title Frag

func (*Title) HTML

func (t *Title) HTML() (HTML, error)

type Tr

type Tr struct {
    ID    string                 `h:"attr"`
    Class string                 `h:"attr"`
    Style string                 `h:"attr"`
    Data  map[string]interface{} `h:"dict"`
    Inner HTML                   `h:"inner"`
}

func (*Tr) HTML

func (t *Tr) HTML() (HTML, error)

type Ul

type Ul struct {
    ID    string `h:"attr"`
    Class string `h:"attr"`
    Style string `h:"attr"`
    Title string `h:"attr"`
    Inner HTML   `h:"inner"`
}

func (*Ul) HTML

func (ul *Ul) HTML() (HTML, error)

type Unsafe

type Unsafe string

func (Unsafe) HTML

func (u Unsafe) HTML() (HTML, error)

func (Unsafe) Write

func (u Unsafe) Write(w io.Writer) (int, error)

type UnsafeBytes

type UnsafeBytes []byte

func (UnsafeBytes) HTML

func (u UnsafeBytes) HTML() (HTML, error)

func (UnsafeBytes) Write

func (u UnsafeBytes) Write(w io.Writer) (int, error)

type XMLNS

type XMLNS map[string]string

func (XMLNS) Attributes

func (ns XMLNS) Attributes() Attributes

Package h imports 11 packages (graph) and is imported by 9 packages. Updated 2013-09-19. Refresh now. Tools for package owners.