private function getDocumentWithPath(\Twig_Environment $twig, $filePath)
{
$globals = $twig->getGlobals();
$documents = $globals['carew']->documents;
if (!array_key_exists($filePath, $documents)) {
throw new \InvalidArgumentException(sprintf('The document with path "%s" does not exist.', $filePath));
}
return $documents[$filePath];
}