Skip to content

[TwigComponent] Html-like attributes aren't parsed correctly #829

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

Closed
Jupi007 opened this issue May 1, 2023 · 3 comments
Closed

[TwigComponent] Html-like attributes aren't parsed correctly #829

Jupi007 opened this issue May 1, 2023 · 3 comments

Comments

@Jupi007
Copy link

Jupi007 commented May 1, 2023

Some attributes are not parsed correctly and throw exceptions or render badly when using html-like syntax.

All these ones works fine:

<twig:foo id="bar" />
{% set id = 'bar' %}
<twig:foo :id="id" />
<twig:foo id="{{ id }}" />
{% set id = 'foo' %}
{% set idSuffix = 'bar' %}
<twig:foo :id="id ~ idSuffix" />

But these ones aren't working as expected:

{% set id = 'bar' %}
<twig:foo id="prefix-{{ id }}" />

Twig\Error\SyntaxError:
Expected attribute name when parsing the "<twig:foo" syntax.
{% set id = 'bar' %}
<twig:foo id="{{ id }}-suffix" />

{# No exception, but only the id var is passed to the template: #}

<div id="bar"></div>
{# Instead of: #}
<div id="bar-suffix"></div>
{% set id = 'bar' %}
<twig:foo :id="id ~ '-suffix'" />
<twig:foo :id="'prefix-' ~ id" />

Twig\Error\SyntaxError:
Unexpected character "\".

Note: the last one came after I updated my dependencies to get #824, so I think it is a regression because it was working fine before.

@weaverryan
Copy link
Member

Hi!

I just tried all of these (thanks for the GREAT report, btw) and they all work fine. About 1 hour ago, I merged #827, which really overhauled all of this handling. If you grab that commit and still have problems, definitely let me know.

Cheers!

@Jupi007
Copy link
Author

Jupi007 commented May 1, 2023

Hi @weaverryan,
you are right, I just pull the latest changes and now it works like a charm.
I was unlucky to update my dependencies a few hours too early :D

Thanks a lot !

@weaverryan
Copy link
Member

Haha, indeed - it was unlucky timing!

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

No branches or pull requests

2 participants