public function output() {
        $parts = explode('/', $this->output_path);
        // get rid of the filename
        array_pop($parts);

        $path = implode('/', $parts);
        if ($path && !file_exists($path)) {
            if (!mkdir($path, 0777, true)) {
                throw new \Exception("could not make directory $path");
            }
        }

        if (!file_put_contents($this->output_path, $this->render())) {
            throw new \Exception("could not write $filename");
        }
    }