Documentation
¶
Index ¶
- func ConvertBlocksToMap(blocks []BlockInterface) []map[string]any
- func MarshalBlocksToJson(blocks []BlockInterface) (string, error)
- type Block
- func (b *Block) AddChild(child BlockInterface)
- func (b *Block) AddChildren(children []BlockInterface)
- func (b *Block) Children() []BlockInterface
- func (b *Block) HasParameter(key string) bool
- func (b *Block) ID() string
- func (b *Block) Parameter(key string) string
- func (b *Block) Parameters() map[string]string
- func (b *Block) SetChildren(children []BlockInterface)
- func (b *Block) SetID(id string)
- func (b *Block) SetParameter(key, value string)
- func (b *Block) SetParameters(parameters map[string]string)
- func (b *Block) SetType(blockType string)
- func (b *Block) ToJson() (string, error)
- func (b *Block) ToJsonObject() blockJsonObject
- func (b *Block) ToJsonPretty() (string, error)
- func (b *Block) ToMap() map[string]interface{}
- func (b *Block) Type() string
- type BlockBuilderInterface
- type BlockInterface
- func ConvertMapToBlock(blockMap map[string]any) (BlockInterface, error)
- func ConvertMapToBlocks(blocks []map[string]any) []BlockInterface
- func NewBlock() BlockInterface
- func NewBlockFromJson(blockJson string) (BlockInterface, error)
- func NewBlockFromMap(m map[string]interface{}) BlockInterface
- func UnmarshalJsonToBlocks(blocksJson string) ([]BlockInterface, error)
- type ChildrenInterface
- type IDInterface
- type ParametersInterface
- type ToHTMLInterface
- type ToJsonInterface
- type ToJsonObjectInterface
- type ToJsonPrettyInterface
- type ToMapInterface
- type TypeInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertBlocksToMap ¶ added in v0.13.0
func ConvertBlocksToMap(blocks []BlockInterface) []map[string]any
func MarshalBlocksToJson ¶ added in v0.13.0
func MarshalBlocksToJson(blocks []BlockInterface) (string, error)
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) AddChild ¶
func (b *Block) AddChild(child BlockInterface)
func (*Block) AddChildren ¶ added in v0.4.0
func (b *Block) AddChildren(children []BlockInterface)
func (*Block) Children ¶
func (b *Block) Children() []BlockInterface
func (*Block) HasParameter ¶ added in v0.14.0
func (*Block) Parameters ¶
func (*Block) SetChildren ¶
func (b *Block) SetChildren(children []BlockInterface)
func (*Block) SetParameter ¶
func (*Block) SetParameters ¶
func (*Block) ToJsonObject ¶ added in v0.5.1
func (b *Block) ToJsonObject() blockJsonObject
func (*Block) ToJsonPretty ¶
type BlockBuilderInterface ¶ added in v0.14.0
type BlockBuilderInterface interface {
WithID(string) BlockBuilderInterface
WithType(string) BlockBuilderInterface
WithParameters(map[string]string) BlockBuilderInterface
WithChildren([]BlockInterface) BlockBuilderInterface
Build() BlockInterface
}
func NewBlockBuilder ¶ added in v0.14.0
func NewBlockBuilder() BlockBuilderInterface
type BlockInterface ¶
type BlockInterface interface {
IDInterface
ChildrenInterface
ParametersInterface
TypeInterface
// Serialization
ToMapInterface
ToJsonInterface
ToJsonObjectInterface
ToJsonPrettyInterface
}
func ConvertMapToBlock ¶ added in v0.13.0
func ConvertMapToBlock(blockMap map[string]any) (BlockInterface, error)
ConvertMapToBlock converts a map to a block
The map must represent a valid block (have parameters like id, and type), otherwise an error will be returned
Parameters: - blockMap - a map[string]any to convert to a block
Returns: - BlockInterface - a block - error - if the map[string]any is not a valid block
func ConvertMapToBlocks ¶ added in v0.13.0
func ConvertMapToBlocks(blocks []map[string]any) []BlockInterface
func NewBlock ¶
func NewBlock() BlockInterface
NewBlock returns a new block instance, and sets the default ID
func NewBlockFromJson ¶ added in v0.13.0
func NewBlockFromJson(blockJson string) (BlockInterface, error)
func NewBlockFromMap ¶ added in v0.13.0
func NewBlockFromMap(m map[string]interface{}) BlockInterface
BlockFromMap creates a block from a map
func UnmarshalJsonToBlocks ¶ added in v0.13.0
func UnmarshalJsonToBlocks(blocksJson string) ([]BlockInterface, error)
type ChildrenInterface ¶ added in v0.11.0
type ChildrenInterface interface {
Children() []BlockInterface
SetChildren([]BlockInterface)
AddChild(BlockInterface)
AddChildren([]BlockInterface)
}
type IDInterface ¶ added in v0.11.0
type ParametersInterface ¶ added in v0.11.0
type ToHTMLInterface ¶ added in v0.11.0
type ToHTMLInterface interface {
ToHTML() string
}
type ToJsonInterface ¶ added in v0.11.0
type ToJsonObjectInterface ¶ added in v0.11.0
type ToJsonObjectInterface interface {
ToJsonObject() blockJsonObject
}
type ToJsonPrettyInterface ¶ added in v0.11.0
type ToMapInterface ¶ added in v0.11.0
type ToMapInterface interface {
ToMap() map[string]interface{}
}
type TypeInterface ¶ added in v0.11.0
Click to show internal directories.
Click to hide internal directories.