{#

  This module implements some common logic to special case some blocks
  so that they render over the entire width of the page.  This is done
  because there is no nice way via CSS to make child elements extend
  past the parent's container.

  This also special cases the first banner.  If the first item is a
  banner it can inject the calling macro right after it.

#}

{% set full_width_blocks = ['banner', 'slideshow'] %}

{% macro render_container(item, classes) %}
  <div class="container">
    <div class="row">
      <div class="{{ classes }}">
        {{ item }}
      </div>
    </div>
  </div>
{% endmacro %}

{% macro render_full_width_blocks(blocks, classes='col-md-8 col-md-offset-2') %}
  {% if blocks and blocks[0]._flowblock != 'banner' and caller %}
    {{ render_container(caller(), classes) }}
  {% endif %}
  {% for blk in blocks %}
    {% if blk._flowblock in full_width_blocks %}
      {{ blk }}
      {% if loop.first and caller %}{{ render_container(caller(), classes) }}{% endif %}
    {% else %}
      {{ render_container(blk, classes) }}
    {% endif %}
  {% endfor %}
{% endmacro %}
