public function compile($vars = array())
    {
        $out = $this->render($vars);

        $outputFile = $this->getOutputFile();
        $destinationDir = dirname($outputFile);
        if (!is_dir($destinationDir)) {
            mkdir($destinationDir, 0777, true);
        }

        if (!is_dir($outputFile)) {
            file_put_contents($outputFile, $out);
        } else {
            throw new \RuntimeException(sprintf(
                'Output path "%s" is directory.', $outputFile));
        }

        return $out;
    }