Skip to content

Commit

Permalink
Remove attribute if value is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanp committed Nov 5, 2011
1 parent 894dcfa commit e6081e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pakyow-presenter/lib/presenter/view.rb
Expand Up @@ -242,8 +242,12 @@ def method_missing(method, *args)
if value.is_a? Proc
value = value.call(self.doc[attribute])
end

self.doc[attribute] = value

if value.nil?
self.doc.remove_attribute(attribute)
else
self.doc[attribute] = value
end
else
return self.doc[method.to_s]
end
Expand Down Expand Up @@ -305,7 +309,9 @@ def bind_object_to_binding(object, binding, bind_as)
v = v.call(binding[:element][k.to_s])
end

if k == :content
if v.nil?
binding[:element].remove_attribute(k.to_s)
elsif k == :content
bind_value_to_binding(v, binding, binder)
else
binding[:element][k.to_s] = v.to_s
Expand Down

0 comments on commit e6081e1

Please sign in to comment.