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

Spacing of default values in macros #252

Open
EmilePerron opened this issue Jun 21, 2022 · 2 comments
Open

Spacing of default values in macros #252

EmilePerron opened this issue Jun 21, 2022 · 2 comments

Comments

@EmilePerron
Copy link

Hey folks!

Looking at the Twig Coding Standards, there doesn't seem to be a set standard for defining default values in macros.

However, the official documentation for macros uses spaces around the = in its examples.

twigcs currently detects default values in macro definitions as named arguments, and request you use no space around the =. I'm not sure if this is a decision based on the lack of clear standard, or simply a bug.

If this is a bug or an oversight, I'd be happy to look into it and try to work on a quick PR to fix this. I'd just like to validate the desired standard here before getting started.

Steps required to reproduce the problem

  1. Create a macro with a default value
     {%- macro render_a_thing(my_var = null) -%}
        {# some macro content #}
     {%- endmacro -%}
  2. Run twigcs (vendor/friendsoftwig/twigcs/bin/twigcs templates)

Expected Result

No violation found.

Actual Result

l.1 c.31 : ERROR There should be 0 space before the "=" in the named arguments list.
l.1 c.33 : ERROR There should be 0 space after the "=" in the named arguments list.
@Ciloe
Copy link
Collaborator

Ciloe commented Jun 22, 2022

Hi,

I think it's a bug ^^

@Ciloe Ciloe added the bug label Jun 22, 2022
@Ciloe Ciloe added this to the 4.0.0 milestone Jun 22, 2022
@OwlyCode
Copy link
Collaborator

Hello and thank you for reporting this. I think it's a duplicate of #170

I tried to look at the fix a few weeks ago and it's not that easy. We would need some improvement on the code that split parenthesis to make the difference between a macro declaration and other parenthesis (macro call, arithmetic expression, etc...).

@localheinz localheinz removed this from the 4.0.0 milestone Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants