def wrap_accordion(text_body_list):
    """
    Wrap text_body_list in twitter bootstrap accordion. text_body_list must be list with tuple with title and body
    """
    html = ['<div class="accordion" id="accordion2">']

    for i, item in enumerate(text_body_list):
        params = {
            'index': i,
            'title': item[0],
            'body': item[1]
        }

        html.append('''
<div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse%(index)d">
        %(title)s
      </a>
    </div>
    <div id="collapse%(index)d" class="accordion-body collapse">
      <div class="accordion-inner">
        %(body)s
      </div>
    </div>
  </div>
  <br/>
''' % params)
    return mark_safe('\n'.join(html))