Documentation
¶
Index ¶
- Constants
- func AnyToClasslist(v any) []string
- func CheckAttributeName(name string) error
- func CheckClassName(name string) error
- func CheckId(s string) error
- func CheckTagName(name string) error
- func SafeAttributeName(name string) string
- func SafeClassName(name string) string
- func SafeId(s string) string
- func SafeTagName(name string) string
- func Settings() *settingsType
- type Classes
- type ConfirmLinkElement
- type DebugElement
- type ElementI
- type ElementWalkFunc
- type FormElement
- type HtmlDocument
- func (d *HtmlDocument) Body() *Tag
- func (d *HtmlDocument) Charset(charset string) *HtmlDocument
- func (d *HtmlDocument) GetTags() TagList
- func (d *HtmlDocument) Head() *Tag
- func (d *HtmlDocument) Icon(icon string) *HtmlDocument
- func (d *HtmlDocument) String() string
- func (d *HtmlDocument) Stylesheet(href string) *HtmlDocument
- func (d *HtmlDocument) Title(title string) *HtmlDocument
- type HtmlPiece
- func (p *HtmlPiece) Append(v ...any) *HtmlPiece
- func (p *HtmlPiece) AppendElement(e ElementI) *HtmlPiece
- func (p *HtmlPiece) AppendPiece(another_piece *HtmlPiece) *HtmlPiece
- func (p *HtmlPiece) AppendText(text string) *HtmlPiece
- func (p *HtmlPiece) Clear() *HtmlPiece
- func (p *HtmlPiece) GetTags() TagList
- func (p *HtmlPiece) IsEmpty() bool
- func (p *HtmlPiece) Len() int
- func (p *HtmlPiece) RawString() string
- func (p *HtmlPiece) String() string
- func (p *HtmlPiece) Textf(format string, a ...any) *HtmlPiece
- func (p *HtmlPiece) Walk(f ElementWalkFunc, args ...any)
- func (p *HtmlPiece) WalkR(f ElementWalkFunc, args ...any)
- type LabelElement
- type LinkElement
- type ListElement
- type ListItemElement
- type NamedHtmlPieces
- func (np *NamedHtmlPieces) Add(name string, v any)
- func (np *NamedHtmlPieces) Clear()
- func (np *NamedHtmlPieces) Get(name string) *HtmlPiece
- func (np *NamedHtmlPieces) GetOk(name string) (p *HtmlPiece, ok bool)
- func (np *NamedHtmlPieces) IsEmpty(name string) bool
- func (np *NamedHtmlPieces) Set(name string, v any)
- type OptionElement
- type RenderFunc
- type SelectElement
- func (c *SelectElement) AppendOption(option *OptionElement) *SelectElement
- func (c *SelectElement) Attribute(name, value string) *SelectElement
- func (c *SelectElement) Class(v any) *SelectElement
- func (c *SelectElement) GetTags() TagList
- func (c *SelectElement) Id(id string) *SelectElement
- func (c *SelectElement) Option(value any, body any) *OptionElement
- type Styles
- type TableCellElement
- type TableElement
- func (e *TableElement) AppendRow(row *TableRowElement) *TableElement
- func (e *TableElement) Class(v ...any) *TableElement
- func (e *TableElement) EmptyLabel(label string) *TableElement
- func (e *TableElement) GetTags() TagList
- func (e *TableElement) Header(v any) *TableElement
- func (e *TableElement) NewRow() (row *TableRowElement)
- func (e *TableElement) RowCount() int
- type TableRowElement
- type Tag
- func Comment(text string) *Tag
- func Div() *Tag
- func EmptyLabel(label string) *Tag
- func NewTag(tag string) *Tag
- func RenderValue(title, value any) *Tag
- func RenderValueE(title, value any, emptyLabel string) *Tag
- func Span() *Tag
- func Text(text string) *Tag
- func Textf(format string, args ...any) *Tag
- func UnsafeText(text string) *Tag
- func (t *Tag) Append(v ...any) *Tag
- func (e *Tag) Attribute(name, value string) *Tag
- func (e *Tag) AttributeUnsafe(name, unsafeValue string) *Tag
- func (e *Tag) ChildrenCount() int
- func (e *Tag) Class(v ...any) *Tag
- func (e *Tag) Comment(text string) *Tag
- func (e *Tag) GetAttribute(name string) string
- func (e *Tag) GetClasses() *Classes
- func (t *Tag) GetTags() TagList
- func (e *Tag) HasChildren() bool
- func (e *Tag) Id(id string) *Tag
- func (e *Tag) IsComment() bool
- func (t *Tag) IsInline() bool
- func (e *Tag) IsText() bool
- func (e *Tag) IsUnsafeText() bool
- func (t *Tag) String() string
- func (e *Tag) Style(property, value string) *Tag
- func (e *Tag) Styles(v ...any) *Tag
- func (e *Tag) Text(content string) *Tag
- func (e *Tag) Textf(format string, a ...any) *Tag
- func (e *Tag) Title(s string) *Tag
- func (t *Tag) Walk(f ElementWalkFunc, args ...any)
- func (t *Tag) WalkR(f ElementWalkFunc, args ...any)
- type TagList
Constants ¶
const ( TAG_NAME_REGEXP = `^[a-z][a-z0-9\-]{0,255}$` ATTRIBUTE_NAME_REGEXP = `^[a-z][a-z0-9\-\:]{0,255}$` HTML_ID_REGEXP = `^[a-z][a-z0-9\_]{0,255}$` CLASS_NAME_REGEXP = `^\-?[\_a-z][\_\-a-z0-9\-\:]{0,255}$` )
Variables ¶
This section is empty.
Functions ¶
func AnyToClasslist ¶
CSS-classes string (or something stringable) "parser"
func CheckAttributeName ¶
func CheckClassName ¶
func CheckTagName ¶
func SafeAttributeName ¶
func SafeClassName ¶
func SafeTagName ¶
Types ¶
type Classes ¶
type Classes struct {
// contains filtered or unexported fields
}
CSS classes list handling
func NewClasses ¶
func (*Classes) AddFromSet ¶
Adds class(es) from v if no classes from class_set already added
func (*Classes) GetClassList ¶
type ConfirmLinkElement ¶
type ConfirmLinkElement struct {
LinkElement
}
<a> tag with onclick="return confirm('message');"
func NewConfirmLink ¶
func NewConfirmLink(href, confirmMessage string) *ConfirmLinkElement
Html form just to render it
func (*ConfirmLinkElement) GetTags ¶
func (e *ConfirmLinkElement) GetTags() TagList
type DebugElement ¶
type DebugElement struct {
// contains filtered or unexported fields
}
func NewDebugElement ¶
func NewDebugElement(skip int) *DebugElement
func (*DebugElement) Append ¶
func (e *DebugElement) Append(v any) *DebugElement
func (*DebugElement) GetTags ¶
func (e *DebugElement) GetTags() TagList
func (*DebugElement) Textf ¶
func (e *DebugElement) Textf(format string, a ...any) *DebugElement
type ElementI ¶
type ElementI interface {
GetTags() TagList
}
Element is something that can be turned in list of html tags. Very simple elements are: tags itself, html comments or just plain text content. It could be much more complex things like Bootstrap's card for example. Whole HTML document is element as well (see dhtml.Document helper).
func AnyToElement ¶
type ElementWalkFunc ¶
Function to be passed to Walk() or WalkR() methods
type FormElement ¶
type FormElement struct {
// contains filtered or unexported fields
}
func (*FormElement) Append ¶
func (f *FormElement) Append(v ...any) *FormElement
func (*FormElement) Class ¶
func (f *FormElement) Class(v ...any) *FormElement
func (*FormElement) GetTags ¶
func (f *FormElement) GetTags() TagList
func (*FormElement) Method ¶
func (f *FormElement) Method(method string) *FormElement
type HtmlDocument ¶
type HtmlDocument struct {
// contains filtered or unexported fields
}
func NewHtmlDocument ¶
func NewHtmlDocument() *HtmlDocument
func (*HtmlDocument) Body ¶
func (d *HtmlDocument) Body() *Tag
func (*HtmlDocument) Charset ¶
func (d *HtmlDocument) Charset(charset string) *HtmlDocument
func (*HtmlDocument) GetTags ¶
func (d *HtmlDocument) GetTags() TagList
func (*HtmlDocument) Head ¶
func (d *HtmlDocument) Head() *Tag
func (*HtmlDocument) Icon ¶
func (d *HtmlDocument) Icon(icon string) *HtmlDocument
func (*HtmlDocument) String ¶
func (d *HtmlDocument) String() string
func (*HtmlDocument) Stylesheet ¶
func (d *HtmlDocument) Stylesheet(href string) *HtmlDocument
func (*HtmlDocument) Title ¶
func (d *HtmlDocument) Title(title string) *HtmlDocument
type HtmlPiece ¶
type HtmlPiece struct {
// contains filtered or unexported fields
}
HtmlPiece is set of one or several html elements (or no elements at all). Could be tags, complex elements, text content etc. Every HtmlPiece as an element itself (so it can be rendered as HTML).
func Piece ¶
If firstElement is HtmlPiece, return it. Else create new HtmlPiece and add firstElement to its contents.
func (*HtmlPiece) Append ¶
Adds something to the piece: another piece, ElemenetI, any string, Stringer or other value.
func (*HtmlPiece) AppendElement ¶
Adds single element
func (*HtmlPiece) AppendPiece ¶
Adds another piece elements to this one
func (*HtmlPiece) AppendText ¶
Adds text element to piece
func (*HtmlPiece) Walk ¶
func (p *HtmlPiece) Walk(f ElementWalkFunc, args ...any)
Calls f function for each element.
func (*HtmlPiece) WalkR ¶
func (p *HtmlPiece) WalkR(f ElementWalkFunc, args ...any)
Calls f function for each element with recursion.
type LabelElement ¶
type LabelElement struct {
// contains filtered or unexported fields
}
simple <label> element
func NewLabel ¶
func NewLabel() *LabelElement
func (*LabelElement) Append ¶
func (e *LabelElement) Append(v ...any) *LabelElement
<label> contents
func (*LabelElement) Class ¶
func (e *LabelElement) Class(v ...any) *LabelElement
func (*LabelElement) For ¶
func (e *LabelElement) For(targetId string) *LabelElement
func (*LabelElement) GetTags ¶
func (e *LabelElement) GetTags() TagList
func (*LabelElement) Styles ¶
func (e *LabelElement) Styles(v ...any) *LabelElement
type LinkElement ¶
type LinkElement struct {
// contains filtered or unexported fields
}
simple <a> element
func NewLink ¶
func NewLink(href string) *LinkElement
func (*LinkElement) Class ¶
func (e *LinkElement) Class(v ...any) *LinkElement
func (*LinkElement) GetTags ¶
func (e *LinkElement) GetTags() TagList
func (*LinkElement) Label ¶
func (e *LinkElement) Label(v any) *LinkElement
func (*LinkElement) Target ¶
func (e *LinkElement) Target(target string) *LinkElement
func (*LinkElement) Title ¶
func (e *LinkElement) Title(title string) *LinkElement
type ListElement ¶
type ListElement struct {
// contains filtered or unexported fields
}
simple <ul> and <ol> elements
func NewOrderedList ¶
func NewOrderedList() *ListElement
func NewUnorderedList ¶
func NewUnorderedList() *ListElement
func (*ListElement) AppendItem ¶
func (e *ListElement) AppendItem(item *ListItemElement) *ListElement
func (*ListElement) Class ¶
func (e *ListElement) Class(v ...any) *ListElement
func (*ListElement) GetTags ¶
func (e *ListElement) GetTags() TagList
func (*ListElement) Item ¶
func (e *ListElement) Item(v ...any) *ListItemElement
func (*ListElement) ItemCount ¶
func (e *ListElement) ItemCount() int
type ListItemElement ¶
type ListItemElement struct {
// contains filtered or unexported fields
}
simple <li> element
func NewListItem ¶
func NewListItem() *ListItemElement
func (*ListItemElement) Append ¶
func (e *ListItemElement) Append(v ...any) *ListItemElement
func (*ListItemElement) Class ¶
func (e *ListItemElement) Class(v ...any) *ListItemElement
func (*ListItemElement) GetTags ¶
func (e *ListItemElement) GetTags() TagList
type NamedHtmlPieces ¶
type NamedHtmlPieces struct {
// contains filtered or unexported fields
}
Set of named html pieces
func NewNamedHtmlPieces ¶
func NewNamedHtmlPieces() NamedHtmlPieces
func (*NamedHtmlPieces) Add ¶
func (np *NamedHtmlPieces) Add(name string, v any)
func (*NamedHtmlPieces) Clear ¶
func (np *NamedHtmlPieces) Clear()
func (*NamedHtmlPieces) Get ¶
func (np *NamedHtmlPieces) Get(name string) *HtmlPiece
func (*NamedHtmlPieces) GetOk ¶
func (np *NamedHtmlPieces) GetOk(name string) (p *HtmlPiece, ok bool)
func (*NamedHtmlPieces) IsEmpty ¶
func (np *NamedHtmlPieces) IsEmpty(name string) bool
func (*NamedHtmlPieces) Set ¶
func (np *NamedHtmlPieces) Set(name string, v any)
type OptionElement ¶
type OptionElement struct {
// contains filtered or unexported fields
}
==================== OptionElement ===================
func NewOption ¶
func NewOption() *OptionElement
func (*OptionElement) Body ¶
func (c *OptionElement) Body(v any) *OptionElement
func (*OptionElement) Selected ¶
func (c *OptionElement) Selected(b bool) *OptionElement
func (*OptionElement) Value ¶
func (c *OptionElement) Value(v any) *OptionElement
type SelectElement ¶
type SelectElement struct {
// contains filtered or unexported fields
}
func NewSelect ¶
func NewSelect() *SelectElement
func (*SelectElement) AppendOption ¶
func (c *SelectElement) AppendOption(option *OptionElement) *SelectElement
func (*SelectElement) Attribute ¶
func (c *SelectElement) Attribute(name, value string) *SelectElement
func (*SelectElement) Class ¶
func (c *SelectElement) Class(v any) *SelectElement
func (*SelectElement) GetTags ¶
func (c *SelectElement) GetTags() TagList
func (*SelectElement) Id ¶
func (c *SelectElement) Id(id string) *SelectElement
func (*SelectElement) Option ¶
func (c *SelectElement) Option(value any, body any) *OptionElement
type Styles ¶
type Styles struct {
// contains filtered or unexported fields
}
styles list handling
type TableCellElement ¶
type TableCellElement struct {
// contains filtered or unexported fields
}
func NewTableCell ¶
func NewTableCell() *TableCellElement
func (*TableCellElement) Append ¶
func (e *TableCellElement) Append(v any) *TableCellElement
func (*TableCellElement) Class ¶
func (e *TableCellElement) Class(v ...any) *TableCellElement
func (*TableCellElement) GetTags ¶
func (e *TableCellElement) GetTags() TagList
type TableElement ¶
type TableElement struct {
// contains filtered or unexported fields
}
simple <table> element
func NewTable ¶
func NewTable() *TableElement
func (*TableElement) AppendRow ¶
func (e *TableElement) AppendRow(row *TableRowElement) *TableElement
Adds <TR> to the table data
func (*TableElement) Class ¶
func (e *TableElement) Class(v ...any) *TableElement
func (*TableElement) EmptyLabel ¶
func (e *TableElement) EmptyLabel(label string) *TableElement
func (*TableElement) GetTags ¶
func (e *TableElement) GetTags() TagList
func (*TableElement) Header ¶
func (e *TableElement) Header(v any) *TableElement
Adds header value (<tr><th>v</th></tr>) to the table
func (*TableElement) NewRow ¶
func (e *TableElement) NewRow() (row *TableRowElement)
Creates new row, appends it to table and returns back
type TableRowElement ¶
type TableRowElement struct {
// contains filtered or unexported fields
}
func NewTableRow ¶
func NewTableRow() *TableRowElement
func (*TableRowElement) AppendCell ¶
func (e *TableRowElement) AppendCell(cell *TableCellElement) *TableRowElement
Add <TD> to the row
func (*TableRowElement) Cell ¶
func (e *TableRowElement) Cell(v any) *TableCellElement
Add new <TD> with given content to the row
func (*TableRowElement) Class ¶
func (e *TableRowElement) Class(v ...any) *TableRowElement
func (*TableRowElement) GetTags ¶
func (e *TableRowElement) GetTags() TagList
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Basic tag element implementation
func EmptyLabel ¶
func RenderValueE ¶
Renders title and some value. If value is empty, render EmptyLabel instead
func UnsafeText ¶
func (*Tag) AttributeUnsafe ¶
func (*Tag) ChildrenCount ¶
func (*Tag) GetAttribute ¶
func (*Tag) GetClasses ¶
func (*Tag) HasChildren ¶
func (*Tag) IsInline ¶
true if this tag could be rendered inline, false - should be rendered on new line and indented.
func (*Tag) IsUnsafeText ¶
func (*Tag) Walk ¶
func (t *Tag) Walk(f ElementWalkFunc, args ...any)
Calls f for each child element
func (*Tag) WalkR ¶
func (t *Tag) WalkR(f ElementWalkFunc, args ...any)
Calls f for each child element with recursion