Module: Merb::Template::Markaby::Mixin

Defined in:
lib/merb_markaby/template.rb

Instance Method Summary collapse

Instance Method Details

#_concat_mab(string, binding) ⇒ Object



46
47
48
# File 'lib/merb_markaby/template.rb', line 46

def _concat_mab(string, binding)
  _mab_buffer(binding) << string
end

#_mab_buffer(binding) ⇒ Object

Provides direct acccess to the buffer for this view context



18
19
20
# File 'lib/merb_markaby/template.rb', line 18

def _mab_buffer( binding )
  @_buffer = eval( "to_s", binding )
end

#capture_mab(*args, &block) ⇒ Object

Allows throw_content and catch_content in .mab views. Same as Merb::Template::Erubis::Mixin#capture_erb



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/merb_markaby/template.rb', line 24

def capture_mab(*args, &block)
  # get the buffer from the block's binding
  buffer = _erb_buffer( block.binding ) rescue nil

  # If there is no buffer, just call the block and get the contents
  if buffer.nil?
    block.call(*args)
  # If there is a buffer, execute the block, then extract its contents
  else
    pos = buffer.length
    block.call(*args)

    # extract the block
    data = buffer[pos..-1]

    # replace it in the original with empty string
    buffer[pos..-1] = ''

    data
  end
end