public static function accordion(array $groups, array $attributes = array()) {
        self::$accordions++;
        $collapse = 1;
        ob_start();
        ?>
        <div data-close="<?= @$attributes['close'] ?>" class="accordion <?= @$attributes['class'] ?>" id="accordion<?= self::$accordions ?>" <?= self::parseAttributes($attributes, array('class', 'id', 'close')) ?>>
            <?php
            foreach ($groups as $key => $group) {
                if (empty($group['heading']) || empty($group['body'])) {
                    throw new Exception('Each accordion group must have a heading and a body');
                }
                ?>
                <div class="accordion-group">
                    <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse"
                           data-parent="#accordion<?= self::$accordions ?>"
                           href="#group-<?= self::$accordions . $key ?>">
                               <?= $group['heading'] ?>
                        </a>
                    </div>
                    <div class="accordion-body collapse in" id="group-<?= self::$accordions . $key ?>">
                        <div class="accordion-inner">
                            <?= $group['body'] ?>
                        </div>
                    </div>
                </div>
                <?php
                $collapse++;
            }
            ?>
        </div>
        <script>
            $(document).ready(function () {
                $('#accordion<?= self::$accordions ?>').collapse();
            })
        </script>
        <?php
        return ob_get_clean();
    }