Skip to content

Conversation

@WebMamba
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
Tickets Fix #803
License MIT

@WebMamba
Copy link
Contributor Author

This is a fix on the HTML twig component syntax but do you think we should extend the fix to allow this
{% component foo:bar for the moment only {% component 'foo:bar' %} is allow?

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this rolling ❤️

'<twig:foo>Foo <twig:bar /><twig:block name="other_block">Other block</twig:block></twig:foo>',
'{% component foo %}{% block content %}Foo {% component bar %}{% endcomponent %}{% endblock %}{% block other_block %}Other block{% endblock %}{% endcomponent %}',
'{% component \'foo\' %}{% block content %}Foo {% component \'bar\' %}{% endcomponent %}{% endblock %}{% block other_block %}Other block{% endblock %}{% endcomponent %}',
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add tests specifically for any of the new character we allow - e.g. <twig:foo:bar or <twig:foo-bar, etc

}

$output .= "{% component {$componentName}".($attributes ? " with { {$attributes} }" : '').' %}';
$output .= "{% component '{$componentName}'".($attributes ? " with { {$attributes} }" : '').' %}';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does {% component @foo/bar-baz.html.twig %} (no ') not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes It works with both

@weaverryan
Copy link
Member

Thanks Matheo!

@weaverryan weaverryan merged commit 4453798 into symfony:2.x Apr 19, 2023
@Jupi007
Copy link

Jupi007 commented Apr 19, 2023

Thanks a lot for the fix @WebMamba !

weaverryan added a commit that referenced this pull request Apr 24, 2023
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

remove / character in the list of allowed character

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Tickets       |
| License       | MIT

By allowing the / character in #806, we introduce a bug. You can't now use the self-closing syntax because it enters in conflict with the component name.
```php
<twig:foo/>
```
The Lexer thinks now that the name is `foo/`
I just remove the / from the allowing list, tell me if you think we should go a bit further.

Commits
-------

cb79adf remove / character in the list of allowed character
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 this pull request may close these issues.

[TwigComponent] namespace double dot isn't parsed correctly

5 participants