Blocks returns a new slice of all the blocks in the body.
()
| 62 | |
| 63 | // Blocks returns a new slice of all the blocks in the body. |
| 64 | func (b *Body) Blocks() []*Block { |
| 65 | ret := make([]*Block, 0, len(b.items)) |
| 66 | for _, n := range b.items.List() { |
| 67 | if block, isBlock := n.content.(*Block); isBlock { |
| 68 | ret = append(ret, block) |
| 69 | } |
| 70 | } |
| 71 | return ret |
| 72 | } |
| 73 | |
| 74 | // GetAttribute returns the attribute from the body that has the given name, |
| 75 | // or returns nil if there is currently no matching attribute. |