From 62e3a771f16a4af90313698f212b4e722194458e Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sat, 29 Oct 2016 16:44:48 -0400 Subject: [PATCH] Move helper into config (faster loading) --- website/config.rb | 11 +++++++++++ website/helpers/sidebar_helpers.rb | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 website/helpers/sidebar_helpers.rb diff --git a/website/config.rb b/website/config.rb index 9df483a2a..d19106d1d 100644 --- a/website/config.rb +++ b/website/config.rb @@ -29,6 +29,17 @@ helpers do return escape_html(page.data.description || "") end + # This helps by setting the "active" class for sidebar nav elements + # if the YAML frontmatter matches the expected value. + def sidebar_current(expected) + current = current_page.data.sidebar_current || "" + if current.start_with?(expected) + return " class=\"active\"" + else + return "" + end + end + # Returns the id for this page. # @return [String] def body_id_for(page) diff --git a/website/helpers/sidebar_helpers.rb b/website/helpers/sidebar_helpers.rb deleted file mode 100644 index 124a7c53c..000000000 --- a/website/helpers/sidebar_helpers.rb +++ /dev/null @@ -1,12 +0,0 @@ -module SidebarHelpers - # This helps by setting the "active" class for sidebar nav elements - # if the YAML frontmatter matches the expected value. - def sidebar_current(expected) - current = current_page.data.sidebar_current || "" - if current.start_with?(expected) - return " class=\"active\"" - else - return "" - end - end -end