-
-
Notifications
You must be signed in to change notification settings - Fork 364
Fix error for component name with : #806
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
Conversation
WebMamba
commented
Apr 19, 2023
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
Tickets | Fix #803 |
License | MIT |
This is a fix on the HTML twig component syntax but do you think we should extend the fix to allow this |
There was a problem hiding this 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 ❤️
]; | ||
|
||
yield 'component_with_default_block_that_holds_a_component_and_multi_blocks' => [ | ||
'<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 %}', | ||
]; |
There was a problem hiding this comment.
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
@@ -58,7 +58,7 @@ public function preLexComponents(string $input): string | |||
$this->currentComponents[] = ['name' => $componentName, 'hasDefaultBlock' => false]; | |||
} | |||
|
|||
$output .= "{% component {$componentName}".($attributes ? " with { {$attributes} }" : '').' %}'; | |||
$output .= "{% component '{$componentName}'".($attributes ? " with { {$attributes} }" : '').' %}'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
1d37aa6
to
ce7f1bf
Compare
Thanks Matheo! |
Thanks a lot for the fix @WebMamba ! |
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