diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2013-12-25 14:49:46 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2013-12-25 14:49:46 +0100 |
commit | bad5fbd942de1d3a059587f595cac2aa50407b15 (patch) | |
tree | 91cd00c0bfc1420795cff6ec83de574b3adc8180 | |
parent | b72598485ace03615a1c39f6a8720c6fe6cfa458 (diff) | |
download | hmnoweb-bad5fbd942de1d3a059587f595cac2aa50407b15.tar.gz hmnoweb-bad5fbd942de1d3a059587f595cac2aa50407b15.tar.bz2 hmnoweb-bad5fbd942de1d3a059587f595cac2aa50407b15.zip |
Refactor filtering of sidebar modules to helper.
Also strip out modules with empty bodies.
-rw-r--r-- | app/helpers/sidebar_helper.rb | 10 | ||||
-rw-r--r-- | app/views/common/_left_sidebar.html.erb | 2 | ||||
-rw-r--r-- | app/views/common/_right_sidebar.html.erb | 2 |
3 files changed, 11 insertions, 3 deletions
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 @@ <div id="left_sidebar"> - <%= render_sidebar_modules @sidebar_modules.select {|m| m.position == 1} %> + <%= render_sidebar_modules @sidebar_modules, :position => 1 %> </div> 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 @@ <div id="right_sidebar"> - <%= render_sidebar_modules @sidebar_modules.select {|m| m.position == 2} %> + <%= render_sidebar_modules @sidebar_modules, :position => 2 %> </div> |