func (state *compileState) popTag(tag []byte) error {
	if len(state.tagStack) > 0 {
		candidate := state.tagStack[len(state.tagStack)-1]
		state.tagStack = state.tagStack[:len(state.tagStack)-1]
		for _, act := range candidate.popActions {
			act()
		}
		if bytes.Equal(candidate.tag, tag) {
			return nil
		}
	}
	return newCompileError(ErrUnexpectedCloseTag, state.tokenizer.Raw(), state.tokenizer.Buffered())
}
/*
popTag removes the tag from the stack and executes any end actions.

popTag keeps removing tags until the one given is found, or no tags remain.
package tal
import (
	"bytes"
	"golang.org/x/net/html"
	"io"
	"sort"
	"strings"
)
type logFunc func(fmt string, args ...interface{})
func defaultLogger(fmt string, args ...interface{}) {
}
type endActionFunc func()
type startActionFunc func(originalAttributes []html.Attribute, talValue string, state *compileState) *CompileError
type tagInfo struct {
	tag        []byte
	popActions []endActionFunc
}
type compileState struct {
	tagStack []tagInfo
	template *Template
	tokenizer *html.Tokenizer
	talStartTag *renderStartTag
	talEndTag *renderEndTag
	nextId int
	currentMacro *useMacro
}
func (state *compileState) addTag(tag []byte) {
	state.tagStack = append(state.tagStack, tagInfo{tag: tag})
}
func (state *compileState) appendAction(action endActionFunc) {
	state.tagStack[len(state.tagStack)-1].popActions = append(state.tagStack[len(state.tagStack)-1].popActions, action)
}
func (state *compileState) insertAction(action endActionFunc) {
	state.tagStack[len(state.tagStack)-1].popActions = append(state.tagStack[len(state.tagStack)-1].popActions, action)
	copy(state.tagStack[len(state.tagStack)-1].popActions[1:], state.tagStack[len(state.tagStack)-1].popActions[:])
	state.tagStack[len(state.tagStack)-1].popActions[0] = action
}