public function render(Path $path)
    {
        $html = null;
        $t = new TemplateLocator($path);
        foreach ($t->next() as $template) {
            $context = $this->buildContext($path, $template);

            // Skip template if no valid context could be created.
            if ($context === null) continue;

            // If abort() wasn't called in template, and it returned some HTML, we'll break and return this.
            $html = $this->renderOrAbort($template, $context);
            if ($html !== null) break;
        }
        if ($html === null) {
            // If no match is found, it might be that we're looking for an "index" model, so append "/index" adn try
            // again.
            $pathWithoutExt = explode('/', $path->getWithoutExtension());
            $fileWithoutExt = end($pathWithoutExt);
            if ($fileWithoutExt !== 'index') {
                return $this->render(new Path($path . '/index'));
            }

            // Nope, this really is a 404.
            return null;
        }

        // What ContentLoaders / Models were accessed during render?
        foreach ($this->resources as $modelName => $resource) {
            if ($resource->wasAccessed()) {
                $this->dispatcher->dispatch(
                    RenderDependencyEvent::NAME, new RenderDependencyEvent($modelName, $path)
                );
            }
        }

        $this->dispatcher
            ->dispatch(RenderEvent::NAME, new RenderEvent($path, $html));

        return $html;
    }