Permalink
Browse files

Replaced explicit Markdown parsing with Twig builtin one

Also check whether included file is defined and non-empty
  • Loading branch information...
1 parent 5ea0f20 commit bc7383542ba8226d9954aaa142bd6fcd029dedb2 Baldur Rensch committed Aug 28, 2012
Showing with 4 additions and 7 deletions.
  1. +1 −6 Formatter/HtmlFormatter.php
  2. +3 −1 Resources/views/method.html.twig
@@ -12,7 +12,6 @@
namespace Nelmio\ApiDocBundle\Formatter;
use Symfony\Component\Templating\EngineInterface;
-use dflydev\markdown\MarkdownParser;
class HtmlFormatter extends AbstractFormatter
{
@@ -91,11 +90,7 @@ protected function renderOne(array $data)
if (!is_readable($data['fileToInclude'])) {
throw new \InvalidArgumentException("Could not open: {$fileToInclude}");
}
-
- $mdParser = new MarkdownParser();
- $fileContents = file_get_contents($data['fileToInclude']);
- $data['fileToInclude'] = $mdParser->transform($fileContents);
-
+ $data['fileToInclude'] = file_get_contents($data['fileToInclude']);
}
return $this->engine->render('NelmioApiDocBundle::resource.html.twig', array_merge(
@@ -28,7 +28,9 @@
{% if data.documentation is defined and data.documentation is not empty %}
<h4>Documentation</h4>
<div>{{ data.documentation|extra_markdown }}</div>
- <div>{{ data.fileToInclude|raw }}</div>
+ {% if data.fileToInclude is defined and data.fileToInclude is not empty %}
+ <div>{{ data.fileToInclude|markdown }}</div>
+ {% endif %}
{% endif %}
{% if data.responseCodes is defined and data.responseCodes is not empty %}

0 comments on commit bc73835

Please sign in to comment.