{% macro build_line(b, include_builder=False) %}
  <small>({{ b.time }})</small>
  Rev: {% if b.multiple_revs -%}
          multiple rev
       {%- else -%}
          {{ b.rev_list[0]['rev']|shortrev(b.rev_list[0]['repo']) }}
       {%- endif %}
  <span class="{{ b.class }}">{{ b.results }}</span>
  {% if include_builder %}
    <a href="{{ b.builderurl }}">{{ b.builder_name }}</a>
  {% endif %}
  <a href="{{ b.buildurl }}">#{{ b.buildnum }}</a> - 
  {{ b.text|capitalize }}
{% endmacro %}

{% macro build_tr(b, include_builder=False, loop=None) %}
  <tr class="{{ loop.cycle('alt', '') if loop }}">
    <td>{{ b.time }}</td>
    <td>{%- for rev in b.rev_list -%}
          {%- if not loop.first %}<br/>{% endif -%}
          {%- if rev.get('codebase', '') %}<span class='codebase'>{{ rev['codebase'] }}</span>:&nbsp;{% endif -%}
          {{ rev['rev']|shortrev(rev['repo']) }}
        {%- endfor -%}
    </td>
    <td class="{{ b.class }}">{{ b.results }}</td>
  {%- if include_builder %}    
    <td><a href="{{ b.builderurl }}">{{ b.builder_name }}</a></td>
  {% endif %}
    <td><a href="{{ b.buildurl }}">#{{ b.buildnum }}</a></td> 
    <td><span class='reason'>{{ b.reason|e }}</span>
      {%- for user in (b.interested_users or []) -%}
        {%- if not loop.first %}, {% endif -%}
        <span class='interested_user'>{{ user|e }}</span>
      {%- endfor -%}
    </td> 
    <td class="left">{{ b.text|capitalize }}</td>
  </tr>
{% endmacro %}

{% macro build_table(builds, include_builder=False) %}
{% if builds %}
<table class="info"> 
  <tr>
    <th>Time</th>
    <th>Revision</th>
    <th>Result</th>
     {%- if include_builder %}   
    <th>Builder</th>
     {% endif %}
    <th>Build #</th>
    <th>Reason</th>
    <th>Info</th>
  </tr>
  {% for b in builds %}
    {{ build_tr(b, include_builder, loop) }}
  {% endfor %}
</table>
{% else %}
  No matching builds found
{% endif %}
{% endmacro %}
