Documentation ¶
Overview ¶
## htmlgo
Type safe and modularize way to generate html on server side. Download the package with `go get -v github.com/theplant/htmlgo` and import the package with `.` gives you simpler code:
import ( . "github.com/theplant/htmlgo" )
also checkout full API documentation at: https://godoc.org/github.com/theplant/htmlgo
Index ¶
- func Fprint(w io.Writer, root HTMLComponent, ctx context.Context) (err error)
- func JSONString(v interface{}) (r string)
- func MustString(root HTMLComponent, ctx context.Context) string
- type ComponentFunc
- type HTMLComponent
- type HTMLComponents
- type HTMLTagBuilder
- func A(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Abbr(text string) (r *HTMLTagBuilder)
- func Address(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Area(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Article(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Aside(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Audio(children ...HTMLComponent) (r *HTMLTagBuilder)
- func B(text string) (r *HTMLTagBuilder)
- func Base(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Bdi(text string) (r *HTMLTagBuilder)
- func Bdo(text string) (r *HTMLTagBuilder)
- func Blockquote(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Body(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Br() (r *HTMLTagBuilder)
- func Button(label string) (r *HTMLTagBuilder)
- func Canvas(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Caption(text string) (r *HTMLTagBuilder)
- func Cite(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Code(text string) (r *HTMLTagBuilder)
- func Col(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Colgroup(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Data(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Datalist(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Dd(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Del(text string) (r *HTMLTagBuilder)
- func Details(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Dfn(text string) (r *HTMLTagBuilder)
- func Dialog(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Div(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Dl(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Dt(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Em(text string) (r *HTMLTagBuilder)
- func Embed(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Fieldset(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Figcaption(text string) (r *HTMLTagBuilder)
- func Figure(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Footer(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Form(children ...HTMLComponent) (r *HTMLTagBuilder)
- func H1(text string) (r *HTMLTagBuilder)
- func H2(text string) (r *HTMLTagBuilder)
- func H3(text string) (r *HTMLTagBuilder)
- func H4(text string) (r *HTMLTagBuilder)
- func H5(text string) (r *HTMLTagBuilder)
- func H6(text string) (r *HTMLTagBuilder)
- func Head(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Header(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Hgroup(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Hr() (r *HTMLTagBuilder)
- func I(text string) (r *HTMLTagBuilder)
- func Iframe(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Img(src string) (r *HTMLTagBuilder)
- func Input(name string) (r *HTMLTagBuilder)
- func Ins(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Kbd(text string) (r *HTMLTagBuilder)
- func Label(text string) (r *HTMLTagBuilder)
- func Legend(text string) (r *HTMLTagBuilder)
- func Li(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Link(href string) (r *HTMLTagBuilder)
- func Main(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Map(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Mark(text string) (r *HTMLTagBuilder)
- func Menu(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Meta() (r *HTMLTagBuilder)
- func Meter(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Nav(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Noscript(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Object(data string) (r *HTMLTagBuilder)
- func Ol(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Optgroup(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Option(text string) (r *HTMLTagBuilder)
- func Output(children ...HTMLComponent) (r *HTMLTagBuilder)
- func P(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Param(name string) (r *HTMLTagBuilder)
- func Picture(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Pre(text string) (r *HTMLTagBuilder)
- func Progress(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Q(text string) (r *HTMLTagBuilder)
- func Rp(text string) (r *HTMLTagBuilder)
- func Rt(text string) (r *HTMLTagBuilder)
- func Ruby(children ...HTMLComponent) (r *HTMLTagBuilder)
- func S(text string) (r *HTMLTagBuilder)
- func Samp(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Script(script string) (r *HTMLTagBuilder)
- func Section(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Select(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Slot(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Small(text string) (r *HTMLTagBuilder)
- func Source(src string) (r *HTMLTagBuilder)
- func Span(text string) (r *HTMLTagBuilder)
- func Strong(text string) (r *HTMLTagBuilder)
- func Style(style string) (r *HTMLTagBuilder)
- func Sub(text string) (r *HTMLTagBuilder)
- func Summary(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Sup(text string) (r *HTMLTagBuilder)
- func Table(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Tag(tag string) (r *HTMLTagBuilder)
- func Tbody(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Td(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Template(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Textarea(text string) (r *HTMLTagBuilder)
- func Tfoot(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Th(text string) (r *HTMLTagBuilder)
- func Thead(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Time(datetime string) (r *HTMLTagBuilder)
- func Title(text string) (r *HTMLTagBuilder)
- func Tr(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Track(src string) (r *HTMLTagBuilder)
- func U(text string) (r *HTMLTagBuilder)
- func Ul(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Var(text string) (r *HTMLTagBuilder)
- func Video(children ...HTMLComponent) (r *HTMLTagBuilder)
- func Wbr(text string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Action(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Alt(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) AppendChildren(c ...HTMLComponent) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Attr(vs ...interface{}) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) AttrIf(key, value interface{}, add bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Charset(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Checked(v bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Children(comps ...HTMLComponent) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Class(names ...string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) ClassIf(name string, add bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Content(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Data(vs ...string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Disabled(v bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) For(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Href(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Id(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)
- func (b *HTMLTagBuilder) Method(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Name(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) OmitEndTag() (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Placeholder(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) PrependChildren(c ...HTMLComponent) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Property(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Readonly(v bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Rel(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Required(v bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Role(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) SetAttr(k string, v interface{})
- func (b *HTMLTagBuilder) Src(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Style(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) StyleIf(v string, add bool) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) TabIndex(v int) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Tag(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Target(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Text(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Title(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Type(v string) (r *HTMLTagBuilder)
- func (b *HTMLTagBuilder) Value(v string) (r *HTMLTagBuilder)
- type IfBuilder
- type IfFuncBuilder
- type MutableAttrHTMLComponent
- type RawHTML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONString ¶
func JSONString(v interface{}) (r string)
func MustString ¶
func MustString(root HTMLComponent, ctx context.Context) string
Types ¶
type ComponentFunc ¶
func (ComponentFunc) MarshalHTML ¶
func (f ComponentFunc) MarshalHTML(ctx context.Context) (r []byte, err error)
type HTMLComponent ¶
func Text ¶
func Text(text string) (r HTMLComponent)
func Textf ¶
func Textf(format string, a ...interface{}) (r HTMLComponent)
type HTMLComponents ¶
type HTMLComponents []HTMLComponent
func Components ¶
func Components(comps ...HTMLComponent) HTMLComponents
func (HTMLComponents) MarshalHTML ¶
func (hcs HTMLComponents) MarshalHTML(ctx context.Context) (r []byte, err error)
type HTMLTagBuilder ¶
type HTMLTagBuilder struct {
// contains filtered or unexported fields
}
func Blockquote ¶
func Blockquote(children ...HTMLComponent) (r *HTMLTagBuilder)
"blockquote": HTMLQuoteElement;
func Canvas ¶
func Canvas(children ...HTMLComponent) (r *HTMLTagBuilder)
"canvas": HTMLCanvasElement;
func Colgroup ¶
func Colgroup(children ...HTMLComponent) (r *HTMLTagBuilder)
"colgroup": HTMLTableColElement;
func Datalist ¶
func Datalist(children ...HTMLComponent) (r *HTMLTagBuilder)
"datalist": HTMLDataListElement;
func Details ¶
func Details(children ...HTMLComponent) (r *HTMLTagBuilder)
func Dialog ¶
func Dialog(children ...HTMLComponent) (r *HTMLTagBuilder)
"dialog": HTMLDialogElement;
func Fieldset ¶
func Fieldset(children ...HTMLComponent) (r *HTMLTagBuilder)
"fieldset": HTMLFieldSetElement;
func Head ¶
func Head(children ...HTMLComponent) (r *HTMLTagBuilder)
func Iframe ¶
func Iframe(children ...HTMLComponent) (r *HTMLTagBuilder)
"iframe": HTMLIFrameElement;
func Input ¶
func Input(name string) (r *HTMLTagBuilder)
func Meta ¶
func Meta() (r *HTMLTagBuilder)
func Noscript ¶
func Noscript(children ...HTMLComponent) (r *HTMLTagBuilder)
"noscript": HTMLElement;
func Optgroup ¶
func Optgroup(children ...HTMLComponent) (r *HTMLTagBuilder)
"optgroup": HTMLOptGroupElement;
func Output ¶
func Output(children ...HTMLComponent) (r *HTMLTagBuilder)
"output": HTMLOutputElement;
func Picture ¶
func Picture(children ...HTMLComponent) (r *HTMLTagBuilder)
"picture": HTMLPictureElement;
func Progress ¶
func Progress(children ...HTMLComponent) (r *HTMLTagBuilder)
"progress": HTMLProgressElement;
func Samp ¶
func Samp(children ...HTMLComponent) (r *HTMLTagBuilder)
func Select ¶
func Select(children ...HTMLComponent) (r *HTMLTagBuilder)
"select": HTMLSelectElement;
func Tag ¶
func Tag(tag string) (r *HTMLTagBuilder)
func Tbody ¶
func Tbody(children ...HTMLComponent) (r *HTMLTagBuilder)
"tbody": HTMLTableSectionElement;
func Template ¶
func Template(children ...HTMLComponent) (r *HTMLTagBuilder)
"template": HTMLTemplateElement;
func Tfoot ¶
func Tfoot(children ...HTMLComponent) (r *HTMLTagBuilder)
"tfoot": HTMLTableSectionElement;
func Thead ¶
func Thead(children ...HTMLComponent) (r *HTMLTagBuilder)
"thead": HTMLTableSectionElement;
func (*HTMLTagBuilder) Action ¶
func (b *HTMLTagBuilder) Action(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Alt ¶
func (b *HTMLTagBuilder) Alt(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) AppendChildren ¶
func (b *HTMLTagBuilder) AppendChildren(c ...HTMLComponent) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Attr ¶
func (b *HTMLTagBuilder) Attr(vs ...interface{}) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) AttrIf ¶
func (b *HTMLTagBuilder) AttrIf(key, value interface{}, add bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Charset ¶
func (b *HTMLTagBuilder) Charset(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Checked ¶
func (b *HTMLTagBuilder) Checked(v bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Children ¶
func (b *HTMLTagBuilder) Children(comps ...HTMLComponent) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Class ¶
func (b *HTMLTagBuilder) Class(names ...string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) ClassIf ¶
func (b *HTMLTagBuilder) ClassIf(name string, add bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Content ¶
func (b *HTMLTagBuilder) Content(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Data ¶
func (b *HTMLTagBuilder) Data(vs ...string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Disabled ¶
func (b *HTMLTagBuilder) Disabled(v bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) For ¶
func (b *HTMLTagBuilder) For(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Href ¶
func (b *HTMLTagBuilder) Href(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Id ¶
func (b *HTMLTagBuilder) Id(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) MarshalHTML ¶
func (b *HTMLTagBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)
func (*HTMLTagBuilder) Method ¶
func (b *HTMLTagBuilder) Method(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Name ¶
func (b *HTMLTagBuilder) Name(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) OmitEndTag ¶
func (b *HTMLTagBuilder) OmitEndTag() (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Placeholder ¶
func (b *HTMLTagBuilder) Placeholder(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) PrependChildren ¶
func (b *HTMLTagBuilder) PrependChildren(c ...HTMLComponent) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Property ¶
func (b *HTMLTagBuilder) Property(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Readonly ¶
func (b *HTMLTagBuilder) Readonly(v bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Rel ¶
func (b *HTMLTagBuilder) Rel(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Required ¶
func (b *HTMLTagBuilder) Required(v bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Role ¶
func (b *HTMLTagBuilder) Role(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) SetAttr ¶
func (b *HTMLTagBuilder) SetAttr(k string, v interface{})
func (*HTMLTagBuilder) Src ¶
func (b *HTMLTagBuilder) Src(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Style ¶
func (b *HTMLTagBuilder) Style(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) StyleIf ¶
func (b *HTMLTagBuilder) StyleIf(v string, add bool) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) TabIndex ¶
func (b *HTMLTagBuilder) TabIndex(v int) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Tag ¶
func (b *HTMLTagBuilder) Tag(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Target ¶
func (b *HTMLTagBuilder) Target(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Text ¶
func (b *HTMLTagBuilder) Text(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Title ¶
func (b *HTMLTagBuilder) Title(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Type ¶
func (b *HTMLTagBuilder) Type(v string) (r *HTMLTagBuilder)
func (*HTMLTagBuilder) Value ¶
func (b *HTMLTagBuilder) Value(v string) (r *HTMLTagBuilder)
type IfBuilder ¶
type IfBuilder struct {
// contains filtered or unexported fields
}
func If ¶
func If(v bool, comps ...HTMLComponent) (r *IfBuilder)
func (*IfBuilder) Else ¶
func (b *IfBuilder) Else(comps ...HTMLComponent) (r *IfBuilder)
type IfFuncBuilder ¶
type IfFuncBuilder struct {
// contains filtered or unexported fields
}
func Iff ¶
func Iff(v bool, f func() HTMLComponent) (r *IfFuncBuilder)
func (*IfFuncBuilder) Else ¶
func (b *IfFuncBuilder) Else(f func() HTMLComponent) (r *IfFuncBuilder)
func (*IfFuncBuilder) ElseIf ¶
func (b *IfFuncBuilder) ElseIf(v bool, f func() HTMLComponent) (r *IfFuncBuilder)
func (*IfFuncBuilder) MarshalHTML ¶
func (b *IfFuncBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)
type MutableAttrHTMLComponent ¶
type MutableAttrHTMLComponent interface { HTMLComponent SetAttr(k string, v interface{}) }