From c38054aaf988cdbe0d3437caa6c86defa7b7475b Mon Sep 17 00:00:00 2001 From: Hassan Khan Date: Mon, 20 Jan 2014 14:16:46 +0000 Subject: [PATCH] Renamed ``Zepto\Zepto::get_sitemap()`` to ``Zepto\Zepto::generate_nav_html()``. This method now generates pre-formatted HTML, rather than a multidimensional array --- library/Zepto/Zepto.php | 20 ++++++++++++++------ templates/base.twig | 6 +----- tests/Zepto/ZeptoTest.php | 18 +++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/library/Zepto/Zepto.php b/library/Zepto/Zepto.php index 7229558..3f1873d 100644 --- a/library/Zepto/Zepto.php +++ b/library/Zepto/Zepto.php @@ -290,19 +290,20 @@ protected function create_nav_links() $content = $container['content']; // Calls protected function which returns formatted array - $nav_items = $this->get_sitemap(); + $nav_html = $this->generate_nav_html(); // Add to ``$container`` - $this->container['nav'] = $nav_items; + $this->container['nav'] = array('nav' => $nav_html); } - protected function get_sitemap() + protected function generate_nav_html() { $container = $this->container; $settings = $container['settings']; $file_loader = $container['file_loader']; + $nav_html = ''; // Could add a hook here maybe? $structure = $file_loader->get_directory_map($settings['zepto']['content_dir']); @@ -314,6 +315,11 @@ protected function get_sitemap() // Check if ``$value`` is an array if (is_array($value)) { + $dropdown_html = '' . PHP_EOL; } // If not then add to ``$nav_items`` else { @@ -339,12 +347,12 @@ protected function get_sitemap() // Create URL $url = $settings['site']['site_root'] . '/' . str_replace($filth, '', $value); - $nav_items[$title] = $url; + $nav_html .= sprintf('
  • %s
  • ' . PHP_EOL, $url, $title); } } } - return $nav_items; + return $nav_html; } // This should be moved into a plugin diff --git a/templates/base.twig b/templates/base.twig index 9534b84..9dbc237 100644 --- a/templates/base.twig +++ b/templates/base.twig @@ -22,11 +22,7 @@

    {{ site_title }}

    diff --git a/tests/Zepto/ZeptoTest.php b/tests/Zepto/ZeptoTest.php index 19f7288..8c4c195 100644 --- a/tests/Zepto/ZeptoTest.php +++ b/tests/Zepto/ZeptoTest.php @@ -144,20 +144,20 @@ public function testLoad_content() /** * @covers Zepto\Zepto::create_nav_links() - * @covers Zepto\Zepto::get_sitemap() + * @covers Zepto\Zepto::generate_nav_html() */ public function testCreateNavLinks() { - $expected = array( - 'Welcome' => 'Site root URL goes here/', - 'Sub' => array( - 'Sub Page Index' => 'Site root URL goes here/sub/', - 'Sub Page' => 'Site root URL goes here/sub/page' - ) - ); + $expected = '
  • Welcome
  • ' . PHP_EOL + . '' . PHP_EOL; $zepto = $this->object; - $this->assertEquals($expected, $zepto->container['nav']); + $this->assertEquals(array('nav' => $expected), $zepto->container['nav']); } /**