kopia lustrzana https://github.com/wagtail/wagtail
Remove use of value.bound_blocks from basic StructBlock template example.
This hasn't been necessary since #1360 was merged, and the new 'BoundBlocks and values' section covers it much better.pull/1889/merge
rodzic
0e34282646
commit
9e124cb9b6
|
@ -441,12 +441,10 @@ Within the template, the block value is accessible as the variable ``value``:
|
|||
<div class="person">
|
||||
{% image value.photo width-400 %}
|
||||
<h2>{{ value.first_name }} {{ value.surname }}</h2>
|
||||
{{ value.bound_blocks.biography.render }}
|
||||
{{ value.biography }}
|
||||
</div>
|
||||
|
||||
|
||||
The line ``value.bound_blocks.biography.render`` warrants further explanation. While blocks such as RichTextBlock are aware of their own rendering, the actual block *values* (as returned when accessing properties of a StructBlock, such as ``value.biography``), are just plain Python values such as strings. To access the block's proper HTML rendering, you must retrieve the 'bound block' - an object which has access to both the rendering method and the value - via the ``bound_blocks`` property.
|
||||
|
||||
.. _streamfield_get_context:
|
||||
|
||||
To pass additional context variables to the template, block subclasses can override the ``get_context`` method:
|
||||
|
|
Ładowanie…
Reference in New Issue