skip_blanks #57

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
3 participants

moktin commented Dec 1, 2012

Hi,

In response to that discussion #56.

Setting the global configuration variable skip_blanks to true (default is false), or passing skip_blanks as an option to a show_for call, stop displaying blank attributes or associations.

lib/show_for/builder.rb
+ # return true if the value is blank and show_for is configured to skip
+ # blank values.
+ def skip?(value) #:nodoc:
+ !!(value.blank? && value != false && ShowFor.skip_blanks)
@rafaelfranca

rafaelfranca Dec 1, 2012

Collaborator

I don't think we need the !!

@moktin

moktin Dec 1, 2012

Right, we don't

@carlosantoniodasilva

carlosantoniodasilva Dec 1, 2012

Collaborator

Please check skip_blanks first, it's an improvement for this option when true.

@@ -5,7 +5,7 @@ def content(value, options={}, apply_options=true, &block)
# cache value for apply_wrapper_options!
sample_value = value
- if value.blank? && value != false
+ if value.blank? && value != false && ShowFor.skip_blanks == false
@rafaelfranca

rafaelfranca Dec 1, 2012

Collaborator

Seems this is identical to skip?, we can reuse the method.

@moktin

moktin Dec 1, 2012

No it is slightly different. In skip?, ShowFor.skip_blanks has to be true.

test/association_test.rb
+ assert_no_select "div.show_for p.wrapper"
+ end
+ end
+
@moktin

moktin Dec 1, 2012

Sorry, you mean that we don't need the last test, or both of them ?

@carlosantoniodasilva

carlosantoniodasilva Dec 1, 2012

Collaborator

Ah sorry, I mean you can kill the blank line 😄

@moktin

moktin Dec 1, 2012

Ok, no problem !

carlosantoniodasilva added a commit that referenced this pull request May 5, 2014

Merge pull request #57 from moktin/master
Add skip_blanks option

Conflicts:
	lib/show_for/content.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment