Documentation ¶
Overview ¶
Trees contain the rendering structures that provide the markup generation for haiku
Index ¶
- Variables
- func AttrContains(e Markup, f, val string) bool
- func Augment(root Markup, m ...Markup)
- func EqualAttributes(e, em Markup) bool
- func RandString(n int) string
- func ReconcileEvents(e, em Markup)
- func StyleContains(e Markup, f, val string) bool
- type Appliable
- type AttrPrinter
- type AttrWriter
- type Attribute
- type Attributes
- type ClassList
- type Clonable
- type Element
- func (e *Element) AddChild(em Markup)
- func (e *Element) Apply(em *Element)
- func (e *Element) Attributes() []*Attribute
- func (e *Element) Augment(m ...Markup)
- func (e *Element) AutoClosed() bool
- func (e *Element) Children() []Markup
- func (e *Element) CleanRemoved()
- func (e *Element) Clone() Markup
- func (e *Element) Empty()
- func (e *Element) EventID() string
- func (e *Element) Events() []*Event
- func (e *Element) LoadEvents()
- func (e *Element) Name() string
- func (e *Element) Reconcile(em Markup) bool
- func (e *Element) Remove()
- func (e *Element) Styles() []*Style
- func (e *Element) TextContent() string
- func (e *Element) UseEventManager(man domevents.EventManagers) bool
- type ElementWriter
- type Event
- type EventHandler
- type Eventers
- type Events
- type Markup
- func DeepElementsUsingStyle(e Markup, f, val string, depth int) []Markup
- func DeepElementsWithAttr(e Markup, f, val string, depth int) []Markup
- func DeepElementsWithTag(e Markup, f string, depth int) []Markup
- func ElementsUsingStyle(e Markup, f, val string) []Markup
- func ElementsWithAttr(e Markup, f, val string) []Markup
- func ElementsWithTag(e Markup, f string) []Markup
- type MarkupChildren
- type MarkupWriter
- type Mutable
- type MutableBackdoor
- type Mutation
- type Reconcilable
- type Style
- type StylePrinter
- type StyleWriter
- type Styles
- type TextPrinter
- type TextWriter
Constants ¶
This section is empty.
Variables ¶
var ErrNotAttr = errors.New("Value type is not n Attribute type")
ErrNotAttr relating to the attribute types
var ErrNotElem = errors.New("Markup is not a *Element type")
ErrNotElem is returned when the markup type does not match the *Element type
var ErrNotFound = errors.New("Item not found")
ErrNotFound relating to the attribute types
var ErrNotMarkup = errors.New("Value does not match Markup interface types")
ErrNotMarkup is returned when the value/pointer type does not match the Markup interface type
var ErrNotStyle = errors.New("Value type is not a Style type")
Errors relating to the style types
var ErrNotText = errors.New("Markup is not a *Text type")
ErrNotText is returned when the markup type is not a text markup
var SimpleAttrWriter = &AttrWriter{}
SimpleAttrWriter provides a basic attribute writer
var SimpleElementWriter = NewElementWriter(SimpleAttrWriter, SimpleStyleWriter, SimpleTextWriter)
SimpleElementWriter provides a default writer using the basic attribute and style writers
var SimpleMarkupWriter = NewMarkupWriter(SimpleElementWriter)
SimpleMarkupWriter provides a basic markup writer for handling the different markup elements
var SimpleStyleWriter = &StyleWriter{}
SimpleStyleWriter provides a basic style writer
var SimpleTextWriter = &TextWriter{}
SimpleTextWriter provides a basic text writer
Functions ¶
func AttrContains ¶
AttrContains returns the attributes that have the specified text within the naming convention and if it also contains the set val if not an empty "", NOTE: string.Contains is used
func EqualAttributes ¶
EqualAttributes returns true/false if the elements and the giving markup have equal attribute
func RandString ¶
RandString generates a set of random numbers of a set length
func ReconcileEvents ¶
func ReconcileEvents(e, em Markup)
ReconcileEvents checks through two markup events against each other and if it finds any disparity marks event objects as Removed
func StyleContains ¶
StyleContains returns the styles that contain the specified name and if the val is not empty then that contains the specified value also, note that strings NOTE: string.Contains is used
Types ¶
type Appliable ¶
type Appliable interface {
Apply(*Element)
}
Appliable define the interface specification for applying changes to elements elements in tree
type AttrPrinter ¶
AttrPrinter defines a printer interface for writing out a Attribute objects into a string form
type AttrWriter ¶
type AttrWriter struct{}
AttrWriter provides a concrete struct that meets the AttrPrinter interface
func (*AttrWriter) Print ¶
func (m *AttrWriter) Print(a []*Attribute) string
Print returns a stringed repesentation of the attribute object
type Attribute ¶
Attribute define the struct for attributes
func GetAttrs ¶
GetAttrs returns the attributes that have the specified text within the naming convention and if it also contains the set val if not an empty "", NOTE: string.Contains is used
type Attributes ¶
type Attributes interface {
Attributes() []*Attribute
}
Attributes interface defines a type that has Attributes
type ClassList ¶
type ClassList struct {
// contains filtered or unexported fields
}
ClassList defines the struct for a lists of classes.
type Clonable ¶
type Clonable interface {
Clone() Markup
}
Clonable defines an interface for objects that can be cloned
type Element ¶
type Element struct { Mutation // contains filtered or unexported fields }
Element represent a concrete implementation of a element node
func NewElement ¶
NewElement returns a new element instance giving the specificed name
func (*Element) Attributes ¶
Attributes return the internal attribute list of the element
func (*Element) AutoClosed ¶
AutoClosed returns true/false if this element uses a </> or a <></> tag convention
func (*Element) CleanRemoved ¶
func (e *Element) CleanRemoved()
CleanRemoved removes all the chilren marked as removed
func (*Element) Empty ¶
func (e *Element) Empty()
Empty resets the elements children list as 0 length
func (*Element) LoadEvents ¶
func (e *Element) LoadEvents()
LoadEvents loads up the events registered by this and by its children into each respective available events managers
func (*Element) Reconcile ¶
Reconcile takes a old markup and reconciles its uid and its children with the new formation,it returns a true/false telling the parent if the children swapped hashes
the reconcilation uses the order in which elements are added, if the order and element types are kept,
then the uid are swapped else it firsts checks the element type and if not the same adds the old one into the new list as removed then continues the check. The system takes position of elements in the old and new as very important and I cant stress this enough, "Element Positioning" in the markup are very important, if a Anchor was the first element in the old render and the next pass returns a Div in the new render, the Anchor will be marked as removed and will be removed from the dom and ignored by the writers. When two elements position are same and their types are the same then a checkup process is doing using the elements attributes, this is done to determine if the hash value of the new should be swapped with the old. We can use style properties here because they are the most volatile of the set and will periodically be either changed and returned to normal values eg display: none to display: block and vise-versa, so only attributes are used in the check process
func (*Element) Remove ¶
func (e *Element) Remove()
Remove sets the markup as removable and adds a 'haikuRemoved' attribute to it
func (*Element) TextContent ¶
TextContent returns the elements text value if its a text type else an empty string
func (*Element) UseEventManager ¶
func (e *Element) UseEventManager(man domevents.EventManagers) bool
UseEventManager adds a eventmanager into the markup and if not available before automatically registers the events with it,once an event manager is registered to it,it will and can not be changed
type ElementWriter ¶
type ElementWriter struct {
// contains filtered or unexported fields
}
ElementWriter writes out the element out as a string matching the html tag rules
func NewElementWriter ¶
func NewElementWriter(aw AttrPrinter, sw StylePrinter, tw TextPrinter) *ElementWriter
NewElementWriter returns a new writer for Element objects
func (*ElementWriter) AllowRemoved ¶
func (m *ElementWriter) AllowRemoved()
AllowRemoved is used to switch off the check to allow rendering of elements set as removed
func (*ElementWriter) DisallowRemoved ¶
func (m *ElementWriter) DisallowRemoved()
DisallowRemoved is used to switch off the check to allow rendering of elements set as removed
func (*ElementWriter) Print ¶
func (m *ElementWriter) Print(e *Element) string
Print returns the string representation of the element
type Event ¶
type Event struct { Meta *domevents.EventMetable Fx domevents.EventHandler // contains filtered or unexported fields }
Event provide a meta registry for helps in registering events for dom markups which is translated to the nodes themselves
func NewEvent ¶
func NewEvent(etype, eselector string, efx EventHandler) *Event
NewEvent returns a event object that allows registering events to eventlisteners
func (*Event) PreventDefault ¶
PreventDefault will return itself and set PreventDefault to true
func (*Event) StopImmediatePropagation ¶
StopImmediatePropagation will return itself and set StopPropagation to true
func (*Event) StopPropagation ¶
StopPropagation will return itself and set StopPropagation to true
type EventHandler ¶
EventHandler provides a custom event handler which allows access to the markup producing the event.
type Eventers ¶
type Eventers interface { LoadEvents() UseEventManager(domevents.EventManagers) bool }
Eventers provide an interface type for elements able to register and load event managers.
type Events ¶
type Events interface {
Events() []*Event
}
Events provide an interface for markup event addition system
type Markup ¶
type Markup interface { Appliable Events Mutation Styles Attributes Clonable MarkupChildren Reconcilable Eventers AutoClosed() bool TextContent() string Name() string EventID() string Augment(...Markup) Empty() CleanRemoved() }
Markup provide a basic specification type of how a element resolves its content
func DeepElementsUsingStyle ¶
DeepElementsUsingStyle returns the children within the element matching the style restrictions passed allowing control of search depth NOTE: is uses StyleContains WARNING: depth must start at 1
func DeepElementsWithAttr ¶
DeepElementsWithAttr returns the children within the element matching the attributes restrictions passed allowing control of search depth NOTE: is uses Element.AttrContains WARNING: depth must start at 1
func DeepElementsWithTag ¶
DeepElementsWithTag returns elements matching the tag type in the parent markup and depending on the depth will walk down other children within the children. WARNING: depth must start at 1
func ElementsUsingStyle ¶
ElementsUsingStyle returns the children within the element matching the stlye restrictions passed. NOTE: is uses StyleContains
func ElementsWithAttr ¶
ElementsWithAttr returns the children within the element matching the stlye restrictions passed. NOTE: is uses AttrContains
func ElementsWithTag ¶
ElementsWithTag returns elements matching the tag type in the parent markup children list only without going deeper into children's children lists
type MarkupChildren ¶
MarkupChildren defines the interface of an element that has children
type MarkupWriter ¶
MarkupWriter defines a printer interface for writing out a markup object into a string form
func NewMarkupWriter ¶
func NewMarkupWriter(em *ElementWriter) MarkupWriter
NewMarkupWriter returns a new markup instance
type Mutable ¶
type Mutable struct {
// contains filtered or unexported fields
}
Mutable is a base implementation of the Mutation interface{}
func (*Mutable) Remove ¶
func (m *Mutable) Remove()
Remove marks this mutable as removed making this irreversible
func (*Mutable) UpdateHash ¶
func (m *Mutable) UpdateHash()
UpdateHash updates the mutable hash value
type MutableBackdoor ¶
type MutableBackdoor struct {
M Mutation
}
MutableBackdoor grants access to a mutable swapUID and swapHash methods.
func (MutableBackdoor) SwapHash ¶
func (m MutableBackdoor) SwapHash(hash string)
SwapHash swaps the hash of the internal mutable.
func (MutableBackdoor) SwapUID ¶
func (m MutableBackdoor) SwapUID(uid string)
SwapUID swaps the uid of the internal mutable.
type Mutation ¶
type Mutation interface { UID() string Hash() string Removed() bool Remove() UpdateHash() // contains filtered or unexported methods }
Mutation defines the capability of an element to state its state if mutation occured
type Reconcilable ¶
Reconcilable defines the interface of markups that can reconcile their content against another
type Style ¶
Style define the style specification for element styles
func GetStyles ¶
GetStyles returns the styles that contain the specified name and if not empty that contains the specified value also, note that strings NOTE: string.Contains is used when checking value parameter if present
type StylePrinter ¶
StylePrinter defines a printer interface for writing out a style objects into a string form
type StyleWriter ¶
type StyleWriter struct{}
StyleWriter provides a concrete struct that meets the AttrPrinter interface
func (*StyleWriter) Print ¶
func (m *StyleWriter) Print(s []*Style) string
Print returns a stringed repesentation of the style object
type Styles ¶
type Styles interface {
Styles() []*Style
}
Styles interface defines a type that has Styles
type TextPrinter ¶
TextPrinter defines a printer interface for writing out a text type markup into a string form
type TextWriter ¶
type TextWriter struct{}
TextWriter writes out the text element/node for the vdom into a string
func (*TextWriter) Print ¶
func (m *TextWriter) Print(t Markup) string
Print returns the string representation of the text object