{% macro tabs(tabs_data, active=None, prefix='') %}
<div>

  <ul class="nav nav-tabs" role="tablist">
    {% for tab in tabs_data %}
      <li role="presentation" class="{{ 'active' if tab.id == active else '' }}">
        <a href="#{{ prefix }}{{ tab.id }}" role="tab" data-toggle="tab">{{ tab.name }}</a>
      </li>
    {% endfor %}
  </ul>

</div>
{% endmacro %}


{% macro tab(tab_id, content, active=None, prefix='') %}
<div role="tabpanel" class="tab-pane fade {{ 'active' if tab_id == active }}" id="{{ prefix }}{{ tab_id }}">
  {{ content }}
</div>
{% endmacro %}

{% macro tabs_start() %}
<div class="tab-content">
{% endmacro %}

{% macro tabs_end() %}
</div>
{% endmacro %}


{% macro plot_tabs(plot_func, plot_id_base, plot_name, params, active) %}
  {{ tabs(params, active=active, prefix=plot_id_base) }}
  {{ tabs_start() }}
  {% for param in params %}
    {% set content = plot_func(plot_id_base + param.name, plot_name + param.name, **kwargs) %}
    {{ tab(param.id, content, active=active, prefix=plot_id_base) }}
  {% endfor %}
  {{ tabs_end() }}
{% endmacro %}

{% macro tabs(tabs_data, active=None, prefix='') %}
<div>

  <ul class="nav nav-tabs" role="tablist">
    {% for tab in tabs_data %}
      <li role="presentation" class="{{ 'active' if tab.id == active else '' }}">
        <a href="#{{ prefix }}{{ tab.id }}" role="tab" data-toggle="tab">{{ tab.name }}</a>
      </li>
    {% endfor %}
  </ul>

</div>
{% endmacro %}


{% macro tab(tab_id, content, active=None, prefix='') %}
<div role="tabpanel" class="tab-pane fade {{ 'active' if tab_id == active }}" id="{{ prefix }}{{ tab_id }}">
  {{ content }}
</div>
{% endmacro %}

{% macro tabs_start() %}
<div class="tab-content">
{% endmacro %}

{% macro tabs_end() %}
</div>
{% endmacro %}


{% macro plot_tabs(plot_func, plot_id_base, plot_name, params, active, attr='name') %}
  {{ tabs(params, active=active, prefix=plot_id_base) }}
  {{ tabs_start() }}
  {% for param in params %}
    {% set content = plot_func(plot_id_base + param[attr], plot_name + param.name, **kwargs) %}
    {{ tab(param.id, content, active=active, prefix=plot_id_base) }}
  {% endfor %}
  {{ tabs_end() }}
{% endmacro %}

Allow to costumize plot id attr in tabs
Allow to costumize plot id attr in tabs
