Skip to content
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

partial template #198

Closed
seb-jean opened this issue Feb 24, 2024 · 7 comments
Closed

partial template #198

seb-jean opened this issue Feb 24, 2024 · 7 comments

Comments

@seb-jean
Copy link

Rule(s) related to or rule(s) missing

FileNameRule

Expected behavior

Sometimes we use partial templates. For example for the Symfony demo, there is the file https://github.com/symfony/demo/blob/main/templates/blog/_post.html.twig

I then tested and I got the error below:

Actual behavior

 KO .\templates\blog\_post.html.twig
 ------- ----------------------------------------------------------
  ERROR   >>   | The file name must use snake_case; expected post.

Do you think this behavior should be taken into account?

@VincentLanglet
Copy link
Owner

Do you think this behavior should be taken into account?

Yes, it should be indeed.

@VincentLanglet
Copy link
Owner

Does #199 would solve your issue @seb-jean ?

@seb-jean
Copy link
Author

It's better :).

However, when I have a file like this: tailwind_2_layout.html.twig, I get the error below:

  KO .\templates\form\tailwind_2_layout.html.twig
  ------- -------------------------------------------- ---------------------------
   ERROR >> | The file name must use snake_case; expected tailwind2_layout.

@VincentLanglet
Copy link
Owner

However, when I have a file like this: tailwind_2_layout.html.twig, I get the error below:

  KO .\templates\form\tailwind_2_layout.html.twig
  ------- -------------------------------------------- ---------------------------
   ERROR >> | The file name must use snake_case; expected tailwind2_layout.

I rely on Symfony/string for the case validator.
I check if you string is the same than the one produced by this method
https://github.com/symfony/string/blob/7.0/AbstractUnicodeString.php#L347-L353

And looking at the tests it seems to be an expected behavior https://github.com/symfony/string/blob/7.0/Tests/AbstractAsciiTestCase.php#L1063-L1077

When looking on the net, there is some discussion about should it be name1 or name_1 with maybe a majority of name1. Anyway, I think that if you consider name_1 should be allowed, the discussion would be on Symfony side I think.
And looking at symfony/symfony#34777 and symfony/symfony#34781 it seems like the discussion was already done.

So if you want to really follow the symfony standard, seems like tailwind2_layout is the valid way.

@seb-jean
Copy link
Author

@VincentLanglet
Copy link
Owner

However this file exists in Symfony: symfony/symfony@7.1/src/Symfony/Bridge/Twig/Resources/views/Form/tailwind_2_layout.html.twig

Indeed. I opened an issue on Symfony side symfony/symfony#54051 to know if

  • The fix should be on the templates name
  • The fix should be on the symfony naming standard
  • The fix should be on my side

@VincentLanglet
Copy link
Owner

I'll close this @seb-jean, I consider:

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