class Mustache::Template

def compile_sections(src)

If enumerable, the return value is iterated over (a `for` loop).
If false, the section is not displayed.
If true, the section is displayed.
Sections can return true, false, or an enumerable.

{{#sections}}okay{{/sections}}
def compile_sections(src)
  res = ""
  while src =~ /#{otag}\#([^\}]*)#{ctag}\s*(.+?)#{otag}\/\1#{ctag}\s*/m
    # $` = The string to the left of the last successful match
    res << compile_tags($`)
    name = $1.strip.to_sym.inspect
    code = compile($2)
    ctxtmp = "ctx#{tmpid}"
    res << ev(<<-compiled)
    if v = ctx[#{name}]
      v = [v] if v.is_a?(Hash) # shortcut when passed a single hash
      if v.respond_to?(:each)
        #{ctxtmp} = ctx.dup
        begin
          r = v.map { |h| ctx.update(h); #{code} }.join
        rescue TypeError => e
          raise TypeError,
            "All elements in {{#{name.to_s[1..-1]}}} are not hashes!"
        end
        ctx.replace(#{ctxtmp})
        r
      else
        #{code}
      end
    end
    compiled
    # $' = The string to the right of the last successful match
    src = $'
  end
  res << compile_tags(src)
end