module ActionView::Helpers::CaptureHelper
def capture_erb_with_buffer_with_haml(buffer, *args, &block)
def capture_erb_with_buffer_with_haml(buffer, *args, &block) if is_haml? capture_haml(*args, &block) else capture_erb_with_buffer_without_haml(buffer, *args, &block) end end
def capture_with_haml(*args, &block)
def capture_with_haml(*args, &block) # Rails' #capture helper will just return the value of the block # 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) 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
def capture_with_haml(*args, &block)
def capture_with_haml(*args, &block) if Haml::Helpers.block_is_haml?(block) _hamlout = eval('_hamlout', block.binding) # Necessary since capture_haml checks _hamlout 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 end
def with_output_buffer_with_haml_xss(*args, &block)
def with_output_buffer_with_haml_xss(*args, &block) res = with_output_buffer_without_haml_xss(*args, &block) case res when Array; res.map {|s| Haml::Util.html_safe(s)} when String; Haml::Util.html_safe(res) else; res end end