There are two ways you can go about templating a table: use the built-in html output or access the column and row data directly to code your own.

Automatic table output#

This will simply output a valid html table:

{{ entry.myTableField.table }}

Code your own#

Should you want more control over the output you can just access the column and row data directly instead using {{ entry.myTableField.columns }} and {{ entry.myTableField.rows }}.

Here is an example of how you might do just that:

            {% for col in entry.myTableField.columns %}
                <th align="{{ col.align }}" width="{{ col.width }}">{{ col.heading }}</th>
            {% endfor %}

        {% for row in entry.myTableField.rows %}
                {% for cell in row %}
                    <td align="{{ entry.myTableField.columns[loop.index0].align }}">{{ cell }}</td>
                {% endfor %}
        {% endfor %}

Note that when looping rows you can use the current loop index to find the appropriate alignment value for that column.

Previous ← Requirements