From dfb87d012c30a5a3e2d6c4f2cf0a94d2fd080723 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 17 Apr 2018 18:19:21 -0700 Subject: [PATCH] Use to_css_class for table cell column classes This ensures that columns with spaces in the name will still generate usable CSS class names. Refs #209 --- datasette/templates/_rows_and_columns.html | 2 +- tests/test_html.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/datasette/templates/_rows_and_columns.html b/datasette/templates/_rows_and_columns.html index 8aa2e657..0844b5bb 100644 --- a/datasette/templates/_rows_and_columns.html +++ b/datasette/templates/_rows_and_columns.html @@ -20,7 +20,7 @@ {% for row in display_rows %} {% for cell in row %} - {{ cell.value }} + {{ cell.value }} {% endfor %} {% endfor %} diff --git a/tests/test_html.py b/tests/test_html.py index e13c8b4f..333e4e41 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -183,13 +183,13 @@ def test_table_html_simple_primary_key(app_client): assert ['nofollow'] == a['rel'] assert [ [ - '1', + '1', 'hello' ], [ - '2', + '2', 'world' ], [ - '3', + '3', '' ] ] == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')] @@ -226,7 +226,7 @@ def test_table_html_no_primary_key(app_client): ] == [th.string.strip() for th in table.select('thead th')[2:]] expected = [ [ - '{}'.format(i, i), + '{}'.format(i, i), '{}'.format(i), '{}'.format(i), 'a{}'.format(i), @@ -270,7 +270,7 @@ def test_table_html_compound_primary_key(app_client): )) expected = [ [ - 'a,b', + 'a,b', 'a', 'b', 'c', @@ -285,7 +285,7 @@ def test_table_html_foreign_key_links(app_client): table = Soup(response.body, 'html.parser').find('table') expected = [ [ - '1', + '1', 'hello\xa01', '1' ]