diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3d52101261..2b52ee7299 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -128,6 +128,7 @@ Changelog * Add "soft" client-side validation for `StreamBlock` / `ListBlock` `min_num` / `max_num` (Matt Westcott) * Log accessibility checker results in the console to help developers with troubleshooting (Thibaud Colas) * Disable pointer events on checker highlights to simplify DevTools inspections (Thibaud Colas) + * `StaticBlock` now renders nothing by default when no template is specified (Sævar Öfjörð Magnússon) * Fix: Make `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` setting functional again (Rohit Sharma) * Fix: Enable `richtext` template tag to convert lazy translation values (Benjamin Bach) * Fix: Ensure permission labels on group permissions page are translated where available (Matt Westcott) diff --git a/docs/releases/6.3.md b/docs/releases/6.3.md index 3038e84b7d..116a26e7e7 100644 --- a/docs/releases/6.3.md +++ b/docs/releases/6.3.md @@ -71,6 +71,7 @@ This feature was developed by Bart Cieliński, alexkiro, and Sage Abdullah. * Prompt the user about unsaved changes when editing snippets (Sage Abdullah) * Add support for specifying different preview modes to the "View draft" URL for pages (Robin Varghese) * Implement new designs for the footer actions dropdown with more contrast and larger text (Sage Abdullah) + * `StaticBlock` now renders nothing by default when no template is specified (Sævar Öfjörð Magnússon) ### Bug fixes diff --git a/wagtail/blocks/static_block.py b/wagtail/blocks/static_block.py index 85fb0c5835..88ca712481 100644 --- a/wagtail/blocks/static_block.py +++ b/wagtail/blocks/static_block.py @@ -33,6 +33,9 @@ class StaticBlock(Block): def normalize(self, value): return None + def render_basic(self, value, context=None): + return "" + class Meta: admin_text = None default = None diff --git a/wagtail/tests/test_blocks.py b/wagtail/tests/test_blocks.py index adcf0e097c..f53430a4fb 100644 --- a/wagtail/tests/test_blocks.py +++ b/wagtail/tests/test_blocks.py @@ -5015,6 +5015,11 @@ class TestStaticBlock(unittest.TestCase): result = block.render(None) self.assertEqual(result, "
PostsStaticBlock template
") + def test_render_without_template(self): + block = blocks.StaticBlock() + result = block.render(None) + self.assertEqual(result, "") + def test_serialize(self): block = blocks.StaticBlock() result = block.get_prep_value(None)