 
     # only when the builder approves the new tag we can proceed with announcing
     # the new tag to the parent and to the tree and apply the childrenscope
-    @builder.approve this, newtag, (_, tag) =>
+    @builder.approve 'new', this, newtag, (_, tag) =>
 
         tag.on 'data', events.data = (data) =>
             if @pending[0] is tag

        @builder = this
        @buffer = [] # for child output
        @pending = [] # no open child tag
        @checkers = [] # all the middlewares that have to approve a new tag
        # states
        @closed = no
        # defaults

        else if type is 'text'
            tag.content

    register: (type, checker) ->
        unless type is 'new' or type is 'end'
            throw new Error "only type 'new' or 'end' allowed."
        @checkers[type] ?= []
        @checkers[type].push checker

    approve: (type, parent, tag, callback) ->
        checkers = @checkers[type]?.slice?() ? []

        if type is 'new'
            next = (tag) ->
                checker = checkers.shift() ? callback
                checker(parent, tag, next)

        else if type is 'end'
            [callback, tag] = [tag, parent] # shift arguments
            next = (tag) ->
                checker = checkers.shift() ? callback
                checker(tag, next)
        else
            throw new Error "type '#{type}' not supported."
        # start
        next(tag)

# exports
