Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Json ¶
type Json struct {
Text string `json:",omitempty"`
Path string `json:",omitempty"`
Subs []Json `json:",omitempty"`
}
helper for simple json based loading and saving
type Leaf ¶
type Leaf interface {
// Path returns the URL path for the leaf.
// If it returns an empty string or a string that begins with ~ or $, the leaf
// is not treated as a link.
Path() string
// String returns the string that is used to represent the leaf.
// If the leaf is treated as a link (see Path()), String() would return the
// linked text.
String() string
}
Leaf is the content of a Node It can be used for the html representation of the menu
type Node ¶
type Node struct {
// Edges is a collection of menu nodes that are children the current node
Edges []*Node
// Leaf contains the item of the current node.
// The root node of a menu tree has no leaf (<nil>).
Leaf Leaf
}
Node is a node of a menu tree
func (*Node) FindByPath ¶
FindByPath returns the first node that has the given path by starting with the leaf of m and then going through its egdes. If no node is found, <nil> is returned
func (*Node) FindByText ¶
FindByText returns the first node that has the given text by starting with the leaf and then going through its egdes. If no node is found, <nil> is returned
func (Node) MarshalJSON ¶
func (*Node) RootAt ¶
RootAt looks for the node with the given path and returns its parent node at nesting level depth. It can be used to get a sub menu for the request path within a http handler to show it in the layout at a different place than other parts of the menu tree. The returned node is a copy of the original node (without the leaf) and may not be used to manipulate the original node. For the later, FindByText() or FindByPath() can be used. If a node was found but it has no edges, <nil> is returned.
func (*Node) UnmarshalJSON ¶
UnmarshalJSON([]byte) error
type WriterTo ¶
type WriterTo interface {
// WriterTo returns an io.WriterTo that writes the menu tree for the given root node.
// The leaf matching the given path may be treated in a special way.
// The given path may be seen as "active" or "selected" path.
// The tree should only be visited up to the given depth.
// WriterTo must handle the case when the root is <nil> (empty menu).
WriterTo(root *Node, depth int, path string) io.WriterTo
}
WriterTo provides a WriterTo that writes a representation of a menu tree