You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test_block.html will render by itself in the pattern library without any issue. However, if we have a stream_block.html template that is being used to include some example blocks for a page.body then we see the bug.
Take a page template that includes the following markup:
{% include_block page.body %}
This will repeatedly use a stream_block template to render the blocks in page.body. The yaml for the stream_block instructs the pattern library to render another template story_container.html, which is only used by the pattern library, and includes a list of example blocks to be rendered for page templates. If we add our test_block.html to this like so it renders an error:
story_container.html:
{% include "patterns/molecules/streamfield/blocks/paragraph_block.html" %}
{% include "patterns/molecules/streamfield/blocks/image_block.html" %}
{% include "patterns/molecules/streamfield/blocks/quote_block.html" %}
{% include "patterns/molecules/streamfield/blocks/cta_button_block.html" %}
{% include "patterns/molecules/streamfield/blocks/document_block.html" %}
{% include "patterns/molecules/streamfield/blocks/test_block.html" %}
The error is as follows:
TypeError at /pattern-library/render-pattern/patterns/pages/standardpages/information_page.html
sequence item 1: expected str instance, NoneType found
Request Method: GET
Request URL: http://localhost:8000/pattern-library/render-pattern/patterns/pages/standardpages/information_page.html
Django Version: 3.2.16
Exception Type: TypeError
Exception Value:
sequence item 1: expected str instance, NoneType found
Exception Location: /venv/lib/python3.8/site-packages/django/template/defaulttags.py, line 221, in render
Python Executable: /venv/bin/python
Python Version: 3.8.16
Python Path:
['/app',
'/app',
'/usr/local/lib/python38.zip',
'/usr/local/lib/python3.8',
'/usr/local/lib/python3.8/lib-dynload',
'/venv/lib/python3.8/site-packages']
Server time: Fri, 09 Dec 2022 11:14:38 +0000
If I change the include_block tag in test_block.html to a simple include tag and pass it the template name, then the issue no longer occurs. If I change the pattern library version for my project to 0.6.0 the issue no longer occurs.
Steps to Reproduce
Create a build using pattern library version 0.7.0 or higher
Create a test template as described above, with a forloop and an include_block
Try adding the test template to a story_container type template, being used to render a set of example blocks for page.body in the pattern library.
Technical details
Python version: 3.8.16.
Django version: 3.2.16.
Browser version: Chrome Version 107.0.5304.121 (Official Build) (x86_64).
The text was updated successfully, but these errors were encountered:
Seems that the issue happens with these specific conditions:
Template A includes some Template B
Template B uses a tag that is overriden to display some Template C (in Helen's example, this is include_block from Wagtail)
Templates B and C render properly, but as of django-pattern-library0.7.0, Template A will not render.
helenb
changed the title
Issue with templates that include_block inside a forloop when added to a story_container template
Issue with nested templates and child templates with overridden tags that include another template
Dec 12, 2022
Found a bug? Please fill out the sections below. 👍
Issue Summary
This issue is present in both 0.7.0 and 1.0.0 versions, but not in 0.6.0
You can repeat the issue by creating a simple template called
test_block.html
that includes another template in a for loop usinginclude_block
test_block.html:
test_block.yaml:
test_block.html
will render by itself in the pattern library without any issue. However, if we have astream_block.html
template that is being used to include some example blocks for apage.body
then we see the bug.Take a page template that includes the following markup:
{% include_block page.body %}
This will repeatedly use a
stream_block
template to render the blocks inpage.body
. The yaml for thestream_block
instructs the pattern library to render another templatestory_container.html
, which is only used by the pattern library, and includes a list of example blocks to be rendered for page templates. If we add ourtest_block.html
to this like so it renders an error:story_container.html
:The error is as follows:
If I change the
include_block
tag intest_block.html
to a simpleinclude
tag and pass it the template name, then the issue no longer occurs. If I change the pattern library version for my project to0.6.0
the issue no longer occurs.Steps to Reproduce
Create a build using pattern library version 0.7.0 or higher
Create a test template as described above, with a forloop and an
include_block
Try adding the test template to a
story_container
type template, being used to render a set of example blocks forpage.body
in the pattern library.Technical details
The text was updated successfully, but these errors were encountered: