function it_should_succeed_on_all_positive_tests() { $dir = dirname(__FILE__) . '/data/positive/'; $dh = opendir($dir); while ($file = readdir($dh)) { if ($file[0] == '.' || !preg_match('/\\.haml$/', $file)) { continue; } $haml = $dir . $file; $html = $dir . 'results/' . str_replace(".haml", ".html", $file); $fammel = new Fammel(); try { $fammel->parse_file($haml); } catch (Exception $e) { // None of these should fail $this->fail("Parsing failed: " . $e->getMessage()); } try { $rendered = $fammel->render(); } catch (Exception $e) { // None of these should fail $this->fail('Rendering failed' . $e->getMessage()); } $this->spec($rendered)->should->equal(file_get_contents($html)); } }
/** * * renderHistory - Renders a history page * * Since history is a special case, use this helper function to render it. * * Returns an associative array: {title, content} */ function renderHistory() { $year = $_GET['year']; if ($year == '') { $year = 'index'; } /* Grab the appropriate file contents */ $raw_nav = file_get_contents('content/blocks/hist_nav.markdown'); $raw_content = file_get_contents('content/history/' . $year . '.markdown'); /* Generate the layout */ $fammel = new Fammel(); $fammel->parse_file('layout/history.haml'); $layout = $fammel->render(); /* Create HTML for the nav and content */ $nav_html = Markdown($raw_nav); $content_html = Markdown($raw_content); /* Add the appropriate information to the page */ $layout = str_replace('[nav]', $nav_html, $layout); $layout = str_replace('[content]', $content_html, $layout); /* Return the appropriate information */ return $layout; }
public function compile($text) { $renderer = new Fammel(); $renderer->parse($text); return $renderer->render(); }