Permalink
Browse files

Make sure view objects don't break on lack of items

  • Loading branch information...
1 parent 29ebbf0 commit 126dd51bce8d2af7d80f48cc3d3a7a522b5edd94 @chewbranca chewbranca committed Mar 16, 2012
@@ -1,7 +1,7 @@
- items = vo.dataset
= panel2 do
= large_feature_panel do
- = large_featured_item(items.shift, :class => 'first')
+ = large_featured_item(items.shift, :class => 'first') if items.any?
= small_featured_item_block(:class => 'last') do
- = small_featured_item items.shift, :class => 'top'
- = small_featured_item items.shift
+ = small_featured_item(items.shift, :class => 'top') if items.any?
+ = small_featured_item(items.shift) if items.any?
@@ -1,7 +1,8 @@
- items = vo.dataset
= panel2 do
= medium_feature_panel do
- = medium_featured_item items.shift, :class => 'first'
+ = medium_featured_item items.shift, :class => 'first' if items.any?
= medium_featured_item_block(:class => 'last') do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list items.slice!(0,2)
+ - if items.size >= 2
+ = featured_item_list items.slice!(0,2)
@@ -1,5 +1,5 @@
- items = vo.dataset
= panel2 do
= medium_feature_panel do
- = medium_featured_item items.shift, :class => 'first'
- = medium_featured_item items.shift, :class => 'last'
+ = medium_featured_item items.shift, :class => 'first' if items.any?
+ = medium_featured_item items.shift, :class => 'last' if items.any?
@@ -3,5 +3,6 @@
= medium_feature_panel do
= medium_featured_item_block(:class => 'first') do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list items.slice!(0,2)
- = medium_featured_item items.shift, :class => 'last'
+ - if items.size >= 2
+ = featured_item_list items.slice!(0,2)
+ = medium_featured_item items.shift, :class => 'last' if items.any?
@@ -2,8 +2,8 @@
= panel2 do
= large_feature_panel do
= small_featured_item_block(:class => 'first') do
- = small_featured_item items.shift, :class => 'top'
- = small_featured_item items.shift
+ = small_featured_item items.shift, :class => 'top' if items.any?
+ = small_featured_item items.shift if items.any?
= large_featured_item_block(:class => 'last') do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list items
+ = featured_item_list items if items.any?
@@ -3,7 +3,8 @@
= large_feature_panel do
= large_featured_item_block(:class => 'first') do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list items.slice!(0,3)
+ - if items.size >= 3
+ = featured_item_list items.slice!(0,3)
= small_featured_item_block(:class => 'last') do
- = small_featured_item items.shift, :class => 'top'
- = small_featured_item items.shift
+ = small_featured_item items.shift, :class => 'top' if items.any?
+ = small_featured_item items.shift if items.any?
@@ -4,4 +4,4 @@
= feature_panel do
= medium_featured_item_block do
= panel_bar vt.t(vo.setting.locale_title)
- = single_featured_item(item)
+ = single_featured_item(item) if item
@@ -2,4 +2,4 @@
= panel1 do
= feature_panel do
- = medium_featured_item item
+ = medium_featured_item item if item
@@ -1,10 +1,10 @@
- items = vo.dataset
= panel3 do
= large_feature_panel do
- = large_featured_item(items.shift, :class => 'first')
+ = large_featured_item(items.shift, :class => 'first') if items.any?
= small_featured_item_block do
- = small_featured_item items.shift, :class => 'top'
- = small_featured_item items.shift
+ = small_featured_item items.shift, :class => 'top' if items.any?
+ = small_featured_item items.shift if items.any?
= medium_featured_item_block(:class => 'last') do
= panel_bar vt.t(vo.setting.locale_title)
= featured_item_list items
@@ -1,10 +1,12 @@
- items = vo.dataset
= panel3 do
= large_feature_panel do
- = large_featured_item(items.shift, :class => 'first')
+ = large_featured_item(items.shift, :class => 'first') if items.any?
= medium_featured_item_block() do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list [items.shift, items.shift]
+ - if items.size >= 2
+ = featured_item_list [items.shift, items.shift]
= medium_featured_item_block(:class => 'last') do
= panel_bar vt.t(vo.setting.locale_title)
- = featured_item_list [items.shift, items.shift]
+ - if items.size >= 2
+ = featured_item_list [items.shift, items.shift]
@@ -1,5 +1,5 @@
- items = vo.dataset
= panel3 do
= xlarge_feature_panel do
- = xlarge_featured_item(items.shift, :class => 'first')
- = xlarge_featured_item(items.shift, :class => 'last')
+ = xlarge_featured_item(items.shift, :class => 'first') if items.any?
+ = xlarge_featured_item(items.shift, :class => 'last') if items.any?
@@ -1,8 +1,8 @@
- items = vo.dataset
= panel3 do
= medium_feature_panel do
- = medium_featured_item(items.shift, :class => 'first')
- = medium_featured_item(items.shift)
+ = medium_featured_item(items.shift, :class => 'first') if items.any?
+ = medium_featured_item(items.shift) if items.any?
= medium_featured_item_block(:class => 'last') do
= panel_bar vt.t(vo.setting.locale_title)
= featured_item_list items
@@ -1,6 +1,6 @@
- items = vo.dataset
= panel3 do
= medium_feature_panel do
- = medium_featured_item items.shift, :class => 'first'
- = medium_featured_item items.shift
- = medium_featured_item items.shift, :class => 'last'
+ = medium_featured_item items.shift, :class => 'first' if items.any?
+ = medium_featured_item items.shift if items.any?
+ = medium_featured_item items.shift, :class => 'last' if items.any?
@@ -1,7 +1,7 @@
- items = vo.dataset
= panel3 do
= small_feature_panel do
- = small_featured_item items.shift, :class => 'first'
- = small_featured_item items.shift
- = small_featured_item items.shift
- = small_featured_item items.shift, :class => 'last'
+ = small_featured_item items.shift, :class => 'first' if items.any?
+ = small_featured_item items.shift if items.any?
+ = small_featured_item items.shift if items.any?
+ = small_featured_item items.shift, :class => 'last' if items.any?

0 comments on commit 126dd51

Please sign in to comment.