kopia lustrzana https://github.com/wagtail/wagtail
Use render_basic for StructBlocks (#3393)
Having a StructBlock rendered via a template was inconsistent with other blocks, It also meant that overriding `render_basic()` in a child class did nothing, again unlike all other blocks. Providing a `render_basic()` is useful for block libraries, where a `render_basic()` provides a very minimal implementation with the expectation that developers will provide their own render method via a template.pull/3394/head
rodzic
1e3548e671
commit
9c2f2aac0f
|
@ -1,6 +0,0 @@
|
|||
<dl>
|
||||
{% for key, val in self.items %}
|
||||
<dt>{{ key }}</dt>
|
||||
<dd>{{ val }}</dd>
|
||||
{% endfor %}
|
||||
</dl>
|
|
@ -11,6 +11,7 @@ from django.template.loader import render_to_string
|
|||
from django.utils import six
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.html import format_html, format_html_join
|
||||
|
||||
from .base import Block, DeclarativeSubBlocksMetaclass
|
||||
from .utils import js_dict
|
||||
|
@ -175,9 +176,12 @@ class BaseStructBlock(Block):
|
|||
|
||||
return errors
|
||||
|
||||
def render_basic(self, value, context=None):
|
||||
return format_html('<dl>\n{}\n</dl>', format_html_join(
|
||||
'\n', ' <dt>{}</dt>\n <dd>{}</dd>', value.items()))
|
||||
|
||||
class Meta:
|
||||
default = {}
|
||||
template = "wagtailadmin/blocks/struct.html"
|
||||
form_classname = 'struct-block'
|
||||
form_template = 'wagtailadmin/block_forms/struct.html'
|
||||
# No icon specified here, because that depends on the purpose that the
|
||||
|
|
Ładowanie…
Reference in New Issue