{% macro list_field(name, field, item, url, loop) %}
    {%- set field_val = field(env, item, url, loop) -%}

    {%- if field_val.attrs is defined %}
        {%- set attrs = field_val.attrs %}
    {%- else %}
        {%- set attrs = {} %}
    {%- endif -%}

    <td class="field_{{ name }}{% if field.classname is defined %} {{ field.classname }}{% endif %}{% if field.image %} has-image{% endif %}">
      {%- if field.link_to_item -%}
        <a data-id="{{ item.id }}"
             {%- if read_allowed %} href="{{ url }}"{% endif %}>
          {%- include field.template -%}
        </a>
      {%- else -%}
        {% include field.template %}
      {%- endif -%}
    </td>
{%- endmacro %}



<tr
  {%- block row_class %} class="item {{ row_cls }}
    {%- if item.public is defined -%}
      {%- if item.public %} published{% else %} unpublished{% endif -%}
    {%- endif %}
    {%- if item.state is defined %}
      {%- if item.state == item.DELETED %} deleted{% endif %}
      {%- if item.state == item.ABSENT %} absent{% endif %}
    {%- endif %}"
  {%- endblock %}
  {%- if item.title is defined %} data-title="{{ item.title|striptags }}"{% endif %}>

  {%- block list_fields %}
    {%- for name, field in list_fields.items() %}
      {%- if item.state is not defined or item.state not in (item.ABSENT, item.DELETED) or name == 'id' %}
        {{- list_field(name, field, item, url, loop) -}}
      {% else -%}
        <td class="field_{{ name }}" title="Deleted"></td>
      {%- endif %}
    {%- endfor %}  
  {%- endblock %}

  {%- block item_form %}
    {%- if list_item_form is defined and list_item_form is not none %}

    {%- set items_fieldlist = list_item_form.get_field('items') -%}
    <td class="list-edit-item" style="width:1%">
      {%- set index = row_index|string %}{# reqired to provide index as name, name MUST be string #}
      <input type="hidden" name="{{ items_fieldlist.indices_input_name }}" value="{{ index }}" />
      {%- set f = items_fieldlist.field(name=index) -%}
      {%- if f.error %}
        <div><span class="error">{{ f.error }}</span></div>
      {%- endif %}
      {{- f.widget.render() -}}
    </td>
    {%- endif -%}
  {% endblock %}
</tr>
