public function endsection(string $name = null): void
    {
        // You can specify the section name for sanity-check purpose.
        if (! is_null($name) && $this->sectionStack[0] != $name) {
            throw new \LogicException('unmatched end-section: ' . $name . ', expects: ' . $this->sectionStack[0]);
        }

        $output = ob_get_clean();

        $name = array_shift($this->sectionStack);
        $this->sections[$name] = $output;
    }