private function statusTransitions()
    {
        $this->status = self::STATUS_IN_LAYOUT;
        $this->events->on('f.template.layout', function () {
            if ($this->status & self::STATUS_IN_PARTIAL) {
                throw new LogicException('Is not possible to use $this->layout() in partials.');
            }
            $this->status = self::STATUS_IN_TEMPLATE;
        });
        $this->events->on('f.template.renderlayout', function () {
            $this->status = self::STATUS_IN_LAYOUT;
        });
        $this->events->on('f.template.prepartial', function () {
            $this->status |= self::STATUS_IN_PARTIAL;
        });
        $this->events->on('f.template.afterpartial', function () {
            $this->status ^= self::STATUS_IN_PARTIAL;
        });
        $this->events->on('f.template.renderered', function () {
            $this->stack()->pop();
            if ($this->stack()->count() === 0) {
                $this->status = self::STATUS_RENDERED | self::STATUS_IDLE;
                $this->events->fire('f.renderered', $this);
            }
        });
    }