• Resolved janineisabelle

    (@janineisabelle)


    I’m building a site with Timber and need to adapt the code to output the table for twig. Is this something you can help with?

Viewing 1 replies (of 1 total)
  • Thread Starter janineisabelle

    (@janineisabelle)

    For anyone else who may want to know the answer to this, here’s how you output the table in twig/Timber:

    {% set table = post.get_field('investors_table') %}
    
        {% if table is not empty %}
    
        <table border="0">
    
            {% if table['caption'] is not empty %}
    
                <caption>{{ table['caption'] }}</caption>
    
            {% endif %}
    
            {% if table['header'] is not empty %}
    
                <thead>
                  <tr>
                    {% for cell in table.header %}
                      <th>{{ cell.c }}</th>
                    {% endfor %}
                  </tr>
                </thead>
    
            {% endif %}
    
            <tbody>
    
              {% for row in table.body %}
                <tr>
                    {% for cell in row %}
                    <td>{{ cell.c }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}
    
            </tbody>
        </table>
    
      {% endif %}
Viewing 1 replies (of 1 total)
  • The topic ‘Output table with Timber’ is closed to new replies.