func (s *state) getBlock(name string) *parse.BlockNode {
	for _, blocks := range s.blocks {
		if block, ok := blocks[name]; ok {
			return block
		}
	}
	return nil
}
Method getBlock iterates through each set of blocks, returning the first
block with the given name.
package stick
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"math"
	"regexp"
	"strconv"
	"strings"
	"github.com/tyler-sommer/stick/parse"
)
type state struct {
	out  io.Writer   
	node parse.Node  
	name string     
	meta *metadata  
	current *parse.BlockNode               
	blocks  []map[string]*parse.BlockNode  
	macros  map[string]*parse.MacroNode    
	env   *Env         
	scope *scopeStack  
}
func newState(name string, out io.Writer, ctx map[string]Value, env *Env) *state {
	return &state{
		out:  out,
		node: nil,
		name: name,
		meta: &metadata{make(map[string]string)},
		blocks: make([]map[string]*parse.BlockNode, 0),
		macros: make(map[string]*parse.MacroNode),
		env:   env,
		scope: &scopeStack{[]map[string]Value{ctx}},
	}
}
func (s *state) Env() *Env {
	return s.env
}
func (s *state) Name() string {
	return s.name
}
func (s *state) Scope() ContextScope {
	return s.scope
}
func (s *state) Meta() ContextMetadata {
	return s.meta
}
func (s *state) noexport() {}
type metadata struct {
	attr map[string]string
}
func (m *metadata) All() map[string]string {
	ret := make(map[string]string, len(m.attr))
	for k, v := range m.attr {
		ret[k] = v
	}
	return ret
}
func (m *metadata) Set(name, val string) {
	m.attr[name] = val
}
func (m *metadata) Get(name string) (string, bool) {
	ret, ok := m.attr[name]
	return ret, ok
}
func (m *metadata) noexport() {}
type scopeStack struct {
	scopes []map[string]Value
}
func (s *scopeStack) push() {
	s.scopes = append(s.scopes, make(map[string]Value))
}
func (s *scopeStack) pop() {
	s.scopes = s.scopes[0 : len(s.scopes)-1]
}
func (s *scopeStack) All() map[string]Value {
	res := make(map[string]Value)
	for _, scope := range s.scopes {
		for k, v := range scope {
			res[k] = v
		}
	}
	return res
}
func (s *scopeStack) noexport() {}
func (s *scopeStack) Get(name string) (Value, bool) {
	for i := len(s.scopes); i > 0; i-- {
		scope := s.scopes[i-1]
		if v, ok := scope[name]; ok {
			return v, true
		}
	}
	return nil, false
}
func (s *scopeStack) Set(name string, val Value) {
	for _, scope := range s.scopes {
		if _, ok := scope[name]; ok {
			scope[name] = val
			return
		}
	}
	s.scopes[len(s.scopes)-1][name] = val
}
func (s *scopeStack) setLocal(name string, val Value) {
	s.scopes[len(s.scopes)-1][name] = val
}