module Haml::Helpers
def capture_haml(*args, &block)
- Yieldparam: args - `args`
Other tags:
- Yield: - A block of Haml code that will be converted to a string
Parameters:
-
args(Array) -- Arguments to pass into the block
def capture_haml(*args, &block) buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer with_haml_buffer(buffer) do position = haml_buffer.buffer.length haml_buffer.capture_position = position value = block.call(*args) captured = haml_buffer.buffer.slice!(position..-1) if captured == '' and value != haml_buffer.buffer captured = (value.is_a?(String) ? value : nil) end return nil if captured.nil? return (haml_buffer.options[:ugly] ? captured : prettify(captured)) end ensure haml_buffer.capture_position = nil end