- Issue created by @ctrlADel
- Status changed to Needs review
27 days ago 3:44pm 30 May 2024 - e0ipso Can Picafort
Test only patch is failing with the expected error: https://git.drupalcode.org/issue/drupal-3446933/-/jobs/1730262#L45
Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("We found an unexpected slot that is not declared: [the_slot]. Declare them in "my-banner.component.yml".").
The pipeline with the fix is green.
This is ready to review.
- Status changed to RTBC
27 days ago 5:10pm 30 May 2024 - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
I can reproduce this issue with the Storybook module integration, the patch fixes it, it includes tests, and test-only run is failing.
Code looks good.The only thing I could suggest is a test with two elements nested instead of one, to check that those are traversed from bottom to top, but that might actually be testing twig itself and not our code.
- Status changed to Needs work
24 days ago 3:19pm 2 June 2024 - Status changed to RTBC
17 days ago 5:59am 9 June 2024 - e0ipso Can Picafort
@alexpott while working on an example with
extends
I realized that the trick to forward block contents will not work on extended templates. This is not related to SDC, but a Twig limitation.{# extends-example.twig #} {% extends 'sdc_test:just-a-slot' %} {% set slot_value %} {% block nested_slot %}{% endblock %} {% endset %} {% block the_slot %}Foo {{ slot_value }}{% endblock %}
In the example above there is no scope for
extend-example.twig
to grab the contents of the blocknested_slot
.Since we are extending another template it does not make sense to introduce a new slot/block, you just use the blocks defined by the parent instead. Therefore I think now, that I was wrong in #2 to suggest that we need to support
extends
.Back to RTBC based on the above.
- Status changed to Needs review
8 days ago 8:41pm 18 June 2024 - e0ipso Can Picafort
If you are curious about my confusion in #8, I was trying to write a test for 4, before I wrote one for 2:
4. Have embed within extends and forward blocks from the parent to the children.
However, that is not valid Twig. And that is what a I was realizing in #8.
The commit above adds test coverage for extends, and we should be good now.