diff --git a/wagtail/contrib/table_block/templates/table_block/blocks/table.html b/wagtail/contrib/table_block/templates/table_block/blocks/table.html index e377a8ca6b..e7d6f7cb01 100644 --- a/wagtail/contrib/table_block/templates/table_block/blocks/table.html +++ b/wagtail/contrib/table_block/templates/table_block/blocks/table.html @@ -1,9 +1,26 @@ -
- - {% if table_header %} - - - {% for column in table_header %} +
+ {% if table_header %} + + + {% for column in table_header %} + + {% endfor %} + + + {% endif %} + + {% for row in data %} + + {% for column in row %} + {% if first_col_is_header and forloop.first %} - {% endfor %} - - - {% endif %} - - {% for row in data %} - - {% for column in row %} - {% if first_col_is_header and forloop.first %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} - -
+ {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} +
{% if column.strip %} {% if html_renderer %} @@ -13,38 +30,19 @@ {% endif %} {% endif %}
- {% if column.strip %} - {% if html_renderer %} - {{ column.strip|safe|linebreaksbr }} - {% else %} - {{ column.strip|linebreaksbr }} - {% endif %} - {% endif %} - - {% if column.strip %} - {% if html_renderer %} - {{ column.strip|safe|linebreaksbr }} - {% else %} - {{ column.strip|linebreaksbr }} - {% endif %} + {% else %} + + {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} {% endif %} -
-
+ {% endif %} + + {% endif %} + {% endfor %} + + {% endfor %} + + diff --git a/wagtail/contrib/table_block/tests.py b/wagtail/contrib/table_block/tests.py index ccdf72e80b..21b424338f 100644 --- a/wagtail/contrib/table_block/tests.py +++ b/wagtail/contrib/table_block/tests.py @@ -21,7 +21,7 @@ def get_test_html_from_value(value): that's what we expect from the TableBlock. """ data = list(value['data']) # Make a copy - table = '
' + table = '
' if value['first_row_is_table_header']: row_header = data.pop(0) table += '' @@ -39,7 +39,7 @@ def get_test_html_from_value(value): table += '' % tiny_escape(col) first = False table += '' - table += '
%s
' + table += '' return table