From bad5fbd942de1d3a059587f595cac2aa50407b15 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 25 Dec 2013 14:49:46 +0100 Subject: Refactor filtering of sidebar modules to helper. Also strip out modules with empty bodies. --- app/helpers/sidebar_helper.rb | 10 +++++++++- app/views/common/_left_sidebar.html.erb | 2 +- app/views/common/_right_sidebar.html.erb | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/helpers/sidebar_helper.rb b/app/helpers/sidebar_helper.rb index 2ae3e95..f9d4834 100644 --- a/app/helpers/sidebar_helper.rb +++ b/app/helpers/sidebar_helper.rb @@ -1,5 +1,13 @@ module SidebarHelper - def render_sidebar_modules(mods) + def render_sidebar_modules(mods, options = {}) + pos = options.delete(:position) + + unless pos.nil? then + mods = mods.select {|m| m.position == pos} + end + + mods = mods.reject {|m| m.body.empty?} + mods.map { |m| render m.to_partial_path, :sidebar_module => m }.join().html_safe diff --git a/app/views/common/_left_sidebar.html.erb b/app/views/common/_left_sidebar.html.erb index 3cdbe0c..9f5a40f 100644 --- a/app/views/common/_left_sidebar.html.erb +++ b/app/views/common/_left_sidebar.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/common/_right_sidebar.html.erb b/app/views/common/_right_sidebar.html.erb index 082e4f1..e90e858 100644 --- a/app/views/common/_right_sidebar.html.erb +++ b/app/views/common/_right_sidebar.html.erb @@ -1,3 +1,3 @@ -- cgit v1.2.3