Skip to content
Browse files

Minor cleanup in the sinatra integration

  • Loading branch information...
1 parent 73a5e28 commit b42e4098d790cdb2630888cadbd1c8f3be6d6a2b @jeremyevans committed May 1, 2012
Showing with 7 additions and 13 deletions.
  1. +7 −13 lib/forme/sinatra.rb
View
20 lib/forme/sinatra.rb
@@ -21,8 +21,8 @@ def emit(tag)
output << tag.to_s
end
- # Always return nil, so that use with <%= doesn't cause
- # multiple things to be output.
+ # Capture the inside of the inputs, injecting it into the template
+ # if a block is given, or returning it as a string if not.
def inputs(*a, &block)
if block
capture(block){super}
@@ -31,20 +31,19 @@ def inputs(*a, &block)
end
end
- # Always return nil, so that use with <%= doesn't cause
- # multiple things to be output.
+ # Capture the inside of the form, injecting it into the template if
+ # a block is given, or returning it as a string if not.
def form(*a, &block)
if block
capture(block){super}
else
- super
+ capture{super}
end
end
- # If a block is provided, inject an opening tag into the
+ # If a block is given, inject an opening tag into the
# output, inject any given children into the output, yield to the
- # block, inject a closing tag into the output, and the return nil
- # so that usage with <%= doesn't cause multiple things to be output.
+ # block, inject a closing tag into the output.
# If a block is not given, just return the tag created.
def tag(type, attr={}, children=[], &block)
tag = _tag(type, attr, children)
@@ -55,7 +54,6 @@ def tag(type, attr={}, children=[], &block)
yield self
emit(serializer.serialize_close(tag)) if serializer.respond_to?(:serialize_close)
end
- nil
else
tag
end
@@ -98,11 +96,7 @@ def form(obj=nil, attr={}, opts={}, &block)
(obj.is_a?(Hash) ? attr = attr.merge(h) : opts = opts.merge(h))
Form.form(obj, attr, opts, &block)
else
- output = ''
- h = {:output=>output}
- (obj.is_a?(Hash) ? attr = attr.merge(h) : opts = opts.merge(h))
Form.form(obj, attr, opts)
- output
end
end
end

0 comments on commit b42e409

Please sign in to comment.
Something went wrong with that request. Please try again.