protected function getFileOrFail($name)
    {
        if (!$this->filesystem->has($this->resolveTemplateName($name))) {
            throw new Twig_Error_Loader('Template could not be found on the given filesystem');
        }

        $fileObject = $this->filesystem->get($this->resolveTemplateName($name));
        if ($fileObject->isDir()) {
            throw new Twig_Error_Loader('Cannot use directory as template');
        }

        return $fileObject;
    }