lib/haml/helpers/action_view_mods.rb in haml-3.1.1 vs lib/haml/helpers/action_view_mods.rb in haml-3.1.2
- old
+ new
@@ -49,11 +49,14 @@
# if it's not actually in the template context,
# as detected by the existance of an _erbout variable.
# We've got to do the same thing for compatibility.
if is_haml? && block_is_haml?(block)
- capture_haml(*args, &block)
+ value = nil
+ buffer = capture_haml(*args) { value = yield(*args) }
+ return buffer unless buffer.empty?
+ return value if value.is_a?(String)
else
capture_without_haml(*args, &block)
end
end
alias_method :capture_without_haml, :capture
@@ -83,10 +86,19 @@
end
else
module CaptureHelper
def capture_with_haml(*args, &block)
if Haml::Helpers.block_is_haml?(block)
- str = capture_haml(*args, &block)
+ value = nil
+ buffer = capture_haml(*args) { value = yield(*args) }
+ str =
+ if !buffer.empty?
+ buffer
+ elsif value.is_a?(String)
+ value
+ else
+ ''
+ end
return ActionView::NonConcattingString.new(str) if defined?(ActionView::NonConcattingString)
return str
else
capture_without_haml(*args, &block)
end