Wagtail - 更改默认 HTML-StreamField 中 StructBlock 的标签包装器

Wagtail - Change default HTML-Tag wrapper for StructBlock in StreamField

我注意到当我的 StructBlocks 在前端呈现时,它的 html 模板被 div 标签包裹。例如,我想将此 HTML-Tag 更改为 li 标签。

有没有可能做到这一点?

根据文档:

In the default rendering, each block of the stream is wrapped in a element (where my_block_name is the block name given in the StreamField definition). If you wish to provide your own HTML markup, you can instead iterate over the field’s value, and invoke {% include_block %} on each block in turn

https://docs.wagtail.org/en/stable/topics/streamfield.html#template-rendering