We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
StreamField EmbedBlock renders the url only
Given the following setup:

```
class EmbedOnImage(StructBlock):
    embed = EmbedBlock()
    background_image = ImageChooserBlock(required=False)

    class Meta:
        template = 'streamfield_blocks/embed_on_image.html'
```

`{{ self.embed }}` outputs the embed url only in `streamfield_blocks/embed_on_image.html`.

And `EmbedBlock.render_basic` is never called: https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailembeds/blocks.py#L8

Also, if I apply the embed filter too: `{{ self.embed|embed }}` then it outputs nothing because the embed filter won't call `embed_to_frontend_html` either, which would use the correct template to render it: https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailembeds/templatetags/wagtailembeds_tags.py#L14


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `wagtail/wagtailembeds/blocks.py`
Content:
```
1 from wagtail.wagtailcore import blocks
2 
3 from wagtail.wagtailembeds.format import embed_to_frontend_html
4 
5 
6 class EmbedBlock(blocks.URLBlock):
7     def render_basic(self, value):
8         return embed_to_frontend_html(value)
9
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/wagtail/wagtailembeds/blocks.py b/wagtail/wagtailembeds/blocks.py
--- a/wagtail/wagtailembeds/blocks.py
+++ b/wagtail/wagtailembeds/blocks.py
@@ -1,8 +1,62 @@
+from django.utils.encoding import python_2_unicode_compatible
+
 from wagtail.wagtailcore import blocks
 
 from wagtail.wagtailembeds.format import embed_to_frontend_html
 
 
+@python_2_unicode_compatible
+class EmbedValue(object):
+    """
+    Native value of an EmbedBlock. Should, at minimum, have a 'url' property
+    and render as the embed HTML when rendered in a template.
+    NB We don't use a wagtailembeds.model.Embed object for this, because
+    we want to be able to do {{ value.url|embed:max_width=500 }} without
+    doing a redundant fetch of the embed at the default width.
+    """
+    def __init__(self, url):
+        self.url = url
+
+    def __str__(self):
+        return embed_to_frontend_html(self.url)
+
+
 class EmbedBlock(blocks.URLBlock):
-    def render_basic(self, value):
-        return embed_to_frontend_html(value)
+    def get_default(self):
+        # Allow specifying the default for an EmbedBlock as either an EmbedValue or a string (or None).
+        if not self.meta.default:
+            return None
+        elif isinstance(self.meta.default, EmbedValue):
+            return self.meta.default
+        else:
+            # assume default has been passed as a string
+            return EmbedValue(self.meta.default)
+
+    def to_python(self, value):
+        # The JSON representation of an EmbedBlock's value is a URL string;
+        # this should be converted to an EmbedValue (or None).
+        if not value:
+            return None
+        else:
+            return EmbedValue(value)
+
+    def get_prep_value(self, value):
+        # serialisable value should be a URL string
+        if value is None:
+            return ''
+        else:
+            return value.url
+
+    def value_for_form(self, value):
+        # the value to be handled by the URLField is a plain URL string (or the empty string)
+        if value is None:
+            return ''
+        else:
+            return value.url
+
+    def value_from_form(self, value):
+        # convert the value returned from the form (a URL string) to an EmbedValue (or None)
+        if not value:
+            return None
+        else:
+            return EmbedValue(value)

{"golden_diff": "diff --git a/wagtail/wagtailembeds/blocks.py b/wagtail/wagtailembeds/blocks.py\n--- a/wagtail/wagtailembeds/blocks.py\n+++ b/wagtail/wagtailembeds/blocks.py\n@@ -1,8 +1,62 @@\n+from django.utils.encoding import python_2_unicode_compatible\n+\n from wagtail.wagtailcore import blocks\n \n from wagtail.wagtailembeds.format import embed_to_frontend_html\n \n \n+@python_2_unicode_compatible\n+class EmbedValue(object):\n+    \"\"\"\n+    Native value of an EmbedBlock. Should, at minimum, have a 'url' property\n+    and render as the embed HTML when rendered in a template.\n+    NB We don't use a wagtailembeds.model.Embed object for this, because\n+    we want to be able to do {{ value.url|embed:max_width=500 }} without\n+    doing a redundant fetch of the embed at the default width.\n+    \"\"\"\n+    def __init__(self, url):\n+        self.url = url\n+\n+    def __str__(self):\n+        return embed_to_frontend_html(self.url)\n+\n+\n class EmbedBlock(blocks.URLBlock):\n-    def render_basic(self, value):\n-        return embed_to_frontend_html(value)\n+    def get_default(self):\n+        # Allow specifying the default for an EmbedBlock as either an EmbedValue or a string (or None).\n+        if not self.meta.default:\n+            return None\n+        elif isinstance(self.meta.default, EmbedValue):\n+            return self.meta.default\n+        else:\n+            # assume default has been passed as a string\n+            return EmbedValue(self.meta.default)\n+\n+    def to_python(self, value):\n+        # The JSON representation of an EmbedBlock's value is a URL string;\n+        # this should be converted to an EmbedValue (or None).\n+        if not value:\n+            return None\n+        else:\n+            return EmbedValue(value)\n+\n+    def get_prep_value(self, value):\n+        # serialisable value should be a URL string\n+        if value is None:\n+            return ''\n+        else:\n+            return value.url\n+\n+    def value_for_form(self, value):\n+        # the value to be handled by the URLField is a plain URL string (or the empty string)\n+        if value is None:\n+            return ''\n+        else:\n+            return value.url\n+\n+    def value_from_form(self, value):\n+        # convert the value returned from the form (a URL string) to an EmbedValue (or None)\n+        if not value:\n+            return None\n+        else:\n+            return EmbedValue(value)\n", "issue": "StreamField EmbedBlock renders the url only\nGiven the following setup:\n\n```\nclass EmbedOnImage(StructBlock):\n    embed = EmbedBlock()\n    background_image = ImageChooserBlock(required=False)\n\n    class Meta:\n        template = 'streamfield_blocks/embed_on_image.html'\n```\n\n`{{ self.embed }}` outputs the embed url only in `streamfield_blocks/embed_on_image.html`.\n\nAnd `EmbedBlock.render_basic` is never called: https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailembeds/blocks.py#L8\n\nAlso, if I apply the embed filter too: `{{ self.embed|embed }}` then it outputs nothing because the embed filter won't call `embed_to_frontend_html` either, which would use the correct template to render it: https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailembeds/templatetags/wagtailembeds_tags.py#L14\n\n", "before_files": [{"content": "from wagtail.wagtailcore import blocks\n\nfrom wagtail.wagtailembeds.format import embed_to_frontend_html\n\n\nclass EmbedBlock(blocks.URLBlock):\n    def render_basic(self, value):\n        return embed_to_frontend_html(value)\n", "path": "wagtail/wagtailembeds/blocks.py"}], "after_files": [{"content": "from django.utils.encoding import python_2_unicode_compatible\n\nfrom wagtail.wagtailcore import blocks\n\nfrom wagtail.wagtailembeds.format import embed_to_frontend_html\n\n\n@python_2_unicode_compatible\nclass EmbedValue(object):\n    \"\"\"\n    Native value of an EmbedBlock. Should, at minimum, have a 'url' property\n    and render as the embed HTML when rendered in a template.\n    NB We don't use a wagtailembeds.model.Embed object for this, because\n    we want to be able to do {{ value.url|embed:max_width=500 }} without\n    doing a redundant fetch of the embed at the default width.\n    \"\"\"\n    def __init__(self, url):\n        self.url = url\n\n    def __str__(self):\n        return embed_to_frontend_html(self.url)\n\n\nclass EmbedBlock(blocks.URLBlock):\n    def get_default(self):\n        # Allow specifying the default for an EmbedBlock as either an EmbedValue or a string (or None).\n        if not self.meta.default:\n            return None\n        elif isinstance(self.meta.default, EmbedValue):\n            return self.meta.default\n        else:\n            # assume default has been passed as a string\n            return EmbedValue(self.meta.default)\n\n    def to_python(self, value):\n        # The JSON representation of an EmbedBlock's value is a URL string;\n        # this should be converted to an EmbedValue (or None).\n        if not value:\n            return None\n        else:\n            return EmbedValue(value)\n\n    def get_prep_value(self, value):\n        # serialisable value should be a URL string\n        if value is None:\n            return ''\n        else:\n            return value.url\n\n    def value_for_form(self, value):\n        # the value to be handled by the URLField is a plain URL string (or the empty string)\n        if value is None:\n            return ''\n        else:\n            return value.url\n\n    def value_from_form(self, value):\n        # convert the value returned from the form (a URL string) to an EmbedValue (or None)\n        if not value:\n            return None\n        else:\n            return EmbedValue(value)\n", "path": "wagtail/wagtailembeds/blocks.py"}]}