-
-
Notifications
You must be signed in to change notification settings - Fork 356
[TwigComponent] Nested component doesn't work with html syntax #805
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
Comments
Other syntaxes look valid to me. That 2nd error is particularly odd. Are you are the error isn’t being caused by something else in your template? @WebMamba would you be able to check these? I have a test for embedded components (the 2nd example) so I’m surprised that’s not working. |
I've just tried this in an empty template, with just the content of the snippets I pasted above here, and both get the exact same errors. |
Here it seems you're in a component usage context, and if I understood correctly the new syntax, when you use a component, it should be without redefining the <twig:foo>
<twig:bar>
{# ... #}
</twig:bar>
</twig:foo>
|
It is also that I understood :) But I also tested with a different block name: <twig:foo>
<twig:block name="foo">
<twig:bar>
<twig:block name="bar">
{# ... #}
</twig:block>
</twig:bar>
</twig:block>
</twig:foo> And the same exception is thrown. |
@Jupi007 then when using another block name, in a usage context, it means you're overriding a block from the component definition, so in the template of the foo component there must be a block named "foo" |
@yguedidi Do you mean like this? {# templates/index.html.twig #}
<twig:foo>
<twig:block name="foo">
{# ... #}
</twig:block>
</twig:foo> {# templates/components/foo.html.twig #}
{% block foo %}
{% endblock %} If so, I did it this way :) |
Yes this way, so it seems there is indeed something weird 😅 |
Ultimately, the new <twig:Component syntax is must “mapped” internally to the {% component syntax. So that makes life easy: if something works with {% component, then it should work with the new syntax and behave the same way. So yes - definitely a legit bug or two here :). |
Should be fixed now - if you find any more edge cases, please let us know! |
Thanks a lot! I just tested it and I think that a part of the problem is still present. Now this works as expected: <twig:foo>
<twig:block name="content">
<twig:bar>
{# ... #}
</twig:bar>
</twig:block>
</twig:foo> But this one still throw an exception: <twig:foo>
<twig:bar>
{# ... #}
</twig:bar>
</twig:foo>
As far as I understand, the |
Ok good catch! It's an other issue I am working for a patch for it as well 👍Thanks for the report! 😁 |
Let's assume two component
foo
andbar
, which both define a content block.Using the normal syntax, it works as expected:
But using the html syntax:
This throw a
SyntaxError
:Btw, simply write it like this doesn't work too:
This one throw:
But maybe it is how it is expected to work?
The text was updated successfully, but these errors were encountered: