Documentation ¶
Index ¶
- Constants
- func AttrsString(ø *Element) (res string)
- func InnerHtml(ø *Element) (res string)
- func InnerHtmlBf(ø *Element, w io.Writer) (num int64, err error)
- func Is(ø *Element, f flag) bool
- func Post(ø *Element, w io.Writer) (num int, err error)
- func Pre(ø *Element, w io.Writer) (num int, err error)
- type Element
- func (ø *Element) Add(objects ...interface{})
- func (ø *Element) HTML() string
- func (ø *Element) Selector() string
- func (ø *Element) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ø *Element) String() (res string)
- func (ø *Element) Tag() string
- func (e *Element) Template(name string) *template.Template
- func (ø *Element) WriteTo(w io.Writer) (num int64, err error)
- type ElementLike
Constants ¶
const ( IdForbidden flag // element should not have an id attribute ClassForbidden // element should not have a class attribute SelfClosing // element is selfclosing and contains no content Inline // element is an inline element (only for visible elements) FormField // element is a field of a form Invisible // element doesn't render anything visible WithoutEscaping // element does not escape inner Text WithoutDecoration // element just prints the InnerHtml JavascriptSpecialEscaping // content contains javascript and needs special escaping or </ )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Element ¶
type Element struct { Id types.Id Descr types.Descr Parent ElementLike Attributes []types.Attribute Classes []types.Class Children []builtin.Stringer Styles []types.Style // contains filtered or unexported fields }
the base of what becomes a tag when printed
func Elements ¶
func Elements(objects ...interface{}) (t *Element)
empty list of elements and others
func NewElement ¶
contruct a new element with some flags.
the tag constructors A(), Body(),... use these method, see tags.go file for examples
use it for your own tags
the following flags are supported
IdForbidden // element should not have an id attribute ClassForbidden // element should not have a class attribute SelfClosing // element is selfclosing and contains no content Inline // element is an inline element (only for visible elements) Field // element is a field of a form Invisible // element doesn't render anything visible WithoutEscaping // element does not escape inner Text WithoutDecoration // element just prints the InnerHtml
see Add() and Set() methods for how to modify the Element
func (*Element) Add ¶
func (ø *Element) Add(objects ...interface{})
adds new inner content or properties based on Stringer objects and returns an error if changes could not be applied
the following types are handled in a special way:
- Descr: sets a description of the eleent, that with be rendered to a comment
- Style: set a single style
- Styles: sets multiple styles
- Attr: set a single attribute // do not set id or class via Attr(s) directly, use Id() and Class() instead
- Attrs: sets multiple attribute
- Class: adds a class
- Id: sets the id
- *Css: applies the css, see ApplyCss()
the following types are added to the inner content:
- Text: ís escaped if the WithoutEscaping flag isn't set
- Html: is never escaped
If the Stringer can be casted to an Elementer (as Element can), it is added to the inner content as well otherwise it is handled like Text(), that means any type implementing Stringer can be added as (escaped) text func (ø *Element) Add(objects ...interface{}) ElementLike {
type ElementLike ¶
type ElementLike interface { // Tag returns the HTML tag Tag() string // HTML returns the HTML string HTML() string // String returns the same as HTML String() string // Add adds different objects to the element Add(objects ...interface{}) }
ElementLike behaves like an HTML Element.