Skip to content

Commit

Permalink
Add AddMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Feb 12, 2022
1 parent 41b1d45 commit b7b0919
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ast/block.go
Expand Up @@ -87,7 +87,20 @@ func (n *Document) Meta() map[string]interface{} {

// SetMeta sets given metadata to this document.
func (n *Document) SetMeta(meta map[string]interface{}) {
n.meta = meta
if n.meta == nil {
n.meta = map[string]interface{}{}
}
for k, v := range meta {
n.meta[k] = v
}
}

// AddMeta adds given metadata to this document.
func (n *Document) AddMeta(key string, value interface{}) {
if n.meta == nil {
n.meta = map[string]interface{}{}
}
n.meta[key] = value
}

// NewDocument returns a new Document node.
Expand Down

0 comments on commit b7b0919

Please sign in to comment.