Permalink
Browse files

added <r:poll:options:each:unless_first/> and <r:poll:options:each:un…

…less_last/>
  • Loading branch information...
1 parent f8f6436 commit e70fce4101f7758bb04779eff1885e183d56f4d4 @nuex committed Jan 21, 2010
Showing with 49 additions and 0 deletions.
  1. +1 −0 CHANGELOG
  2. +26 −0 lib/poll_tags.rb
  3. +22 −0 spec/lib/poll_tags_spec.rb
View
@@ -1,6 +1,7 @@
=== 0.3.2
* added <r:poll:options:each:if_first/> and <r:poll:options:each:if_last/>
+ * added <r:poll:options:each:unless_first /> and <r:poll:options:each:unless_last/>
=== 0.3.1
View
@@ -170,6 +170,32 @@ class TagError < StandardError; end
end
desc %{
+ Render inner content unless the current contextual option is the first option.
+
+ *Usage:*
+ <pre><code><r:options:each:unless_first>...</r:options:each:unless_first></code></pre>
+ }
+ tag 'poll:options:each:unless_first' do |tag|
+ options = tag.locals.sort_order.nil? ? tag.locals.poll.options : tag.locals.poll.options.sort(&tag.locals.sort_order)
+ unless options.first == tag.locals.option
+ tag.expand
+ end
+ end
+
+ desc %{
+ Render inner content unless the current contextual option is the last option.
+
+ *Usage:*
+ <pre><code><r:options:each:unless_last>...</r:options:each:unless_last></code></pre>
+ }
+ tag 'poll:options:each:unless_last' do |tag|
+ options = tag.locals.sort_order.nil? ? tag.locals.poll.options : tag.locals.poll.options.sort(&tag.locals.sort_order)
+ unless options.last == tag.locals.option
+ tag.expand
+ end
+ end
+
+ desc %{
Show the poll option radio button input type.
*Usage:*
View
@@ -242,6 +242,28 @@
end
+ describe '<r:poll:options:each:unless_first>' do
+
+ it 'should render inner tags only unless the current context is the first option' do
+ tag = %{<r:poll title="Test Poll"><r:options:each><r:unless_first>,</r:unless_first><r:percent_responses /></r:options:each></r:poll>}
+ expected = '60.0,40.0,0.0'
+
+ pages(:home).should render(tag).as(expected)
+ end
+
+ end
+
+ describe '<r:poll:options:each:unless_last>' do
+
+ it 'should render inner tags only unless the current context is the last option' do
+ tag = %{<r:poll title="Test Poll"><r:options:each><r:percent_responses /><r:unless_last>,</r:unless_last></r:options:each></r:poll>}
+ expected = '60.0,40.0,0.0'
+
+ pages(:home).should render(tag).as(expected)
+ end
+
+ end
+
##
## Test poll archives
##

0 comments on commit e70fce4

Please sign in to comment.