Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefining a deferred block that is not the first removes other blocks from rendering #17

Closed
TLG-Gildas opened this issue Mar 8, 2024 · 2 comments · Fixed by #19
Closed

Comments

@TLG-Gildas
Copy link

Redefining a deferred block that is not the first deferred block of the parent template removes other blocks from rendering.

Here is a test to reproduce the issue :

--TEST--
Failed parents override
--TEMPLATE--
{% extends "level1.twig" %}
{% block overrided deferred %}{{ parent() }}:level2({{data|join(', ')}}){% endblock %}
{% do data.append('lazy2') %}
--TEMPLATE(level1.twig)--
{% block bar '[bar]' %}
{% block foo deferred %}[foo]{% endblock %}
{% block baz '[baz]' %}
{% block overrided deferred %}[overrided]{% endblock %}
{% block zoo '[zoo]' %}
{% do data.append('lazy1') %}
--DATA--
return []
--EXPECT--
[bar][foo][baz][overrided]:level2(lazy2, lazy1)[zoo]

This test currently produces this output : [baz][foo][zoo]

This test deliberately adds intermediate blocks to clearly see the abnormal behavior.

Here is a minimal version to reproduce the issue :

--TEST--
Failed parents override simple
--TEMPLATE--
{% extends "level1.twig" %}
{% block overrided deferred %}{{ parent() }}:level2{% endblock %}
--TEMPLATE(level1.twig)--
{% block foo deferred %}[foo]{% endblock %}
{% block overrided deferred %}[overrided]{% endblock %}
--DATA--
return []
--EXPECT--
[foo][overrided]:level2

This test currently produces : [foo]

In both cases, if we swap the foo and overrided blocks in level1.twig, then the expected rendering is correct.

--TEST--
Passed parents override
--TEMPLATE--
{% extends "level1.twig" %}
{% block overrided deferred %}{{ parent() }}:level2({{data|join(', ')}}){% endblock %}
{% do data.append('lazy2') %}
--TEMPLATE(level1.twig)--
{% block bar '[bar]' %}
{% block overrided deferred %}[overrided]{% endblock %}
{% block baz '[baz]' %}
{% block foo deferred %}[foo]{% endblock %}
{% block zoo '[zoo]' %}
{% do data.append('lazy1') %}
--DATA--
return []
--EXPECT--
[bar][overrided]:level2(lazy2, lazy1)[baz][foo][zoo]
--TEST--
Passed parents override simple
--TEMPLATE--
{% extends "level1.twig" %}
{% block overrided deferred %}{{ parent() }}:level2{% endblock %}
--TEMPLATE(level1.twig)--
{% block overrided deferred %}[overrided]{% endblock %}
{% block foo deferred %}[foo]{% endblock %}
--DATA--
return []
--EXPECT--
[overrided]:level2[foo]

For my part, I have not yet managed to find the cause of the bug.
You will undoubtedly be more efficient.

@rybakit
Copy link
Owner

rybakit commented Apr 2, 2024

Hey @TLG-Gildas , thanks for reporting and investigating the issue! I believe it should be fixed by #19.

@TLG-Gildas
Copy link
Author

thanks for the work, unfortunately this doesn't fix the problem, I made a comment in the PR

rybakit added a commit that referenced this issue Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants