From e843ce26e536bb1a105da808c8f765b2c56e9c7b Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 21 Jun 2018 08:26:18 -0700 Subject: [PATCH] Correctly display empty strings in HTML table, closes #314 --- datasette/views/table.py | 2 +- tests/test_html.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datasette/views/table.py b/datasette/views/table.py index 89dec455..07ff6bb7 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -182,7 +182,7 @@ class RowTableShared(BaseView): id=str(jinja2.escape(value)), label=str(jinja2.escape(label)), )) - elif value is None: + elif value in ("", None): display_value = jinja2.Markup(" ") elif is_url(str(value).strip()): display_value = jinja2.Markup( diff --git a/tests/test_html.py b/tests/test_html.py index c3429298..ee9d3c41 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -352,7 +352,7 @@ def test_table_html_simple_primary_key(app_client): 'world' ], [ '3', - '' + '\xa0' ] ] == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')] @@ -585,8 +585,8 @@ def test_view_html(app_client): 'world', 'WORLD' ], [ - '', - '' + '\xa0', + '\xa0' ] ] assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]