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 /app/helpers | |
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.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/sidebar_helper.rb | 10 |
1 files changed, 9 insertions, 1 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 |