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

Allow new lines after opening blocks #58

Open
Chi-teck opened this issue Mar 4, 2019 · 6 comments
Open

Allow new lines after opening blocks #58

Chi-teck opened this issue Mar 4, 2019 · 6 comments

Comments

@Chi-teck
Copy link
Contributor

Chi-teck commented Mar 4, 2019

Drupal core use multiline block statements to set Twig variables like follows.
https://github.com/drupal/drupal/blob/8.6.10/core/themes/classy/templates/block/block.html.twig#L28

Twig coding standard does not forbid this syntax. So I think Twigcs should no complain about that.
Currently it brings ERROR There should be 1 space(s) after opening a block. violation.

Thanks.

@OwlyCode
Copy link
Collaborator

OwlyCode commented Mar 4, 2019

Hello,

As of https://twig.symfony.com/doc/2.x/coding_standards.html it is stated :

Put one (and only one) space after the start of a delimiter ({{, {%, and {#) and before the end of a delimiter (}}, %}, and #}):

My understanding of this is that you should format like this :

{% set classes = [
    'block',
    'block-' ~ configuration.provider|clean_class,
    'block-' ~ plugin_id|clean_class,
] %}

But you can still use custom rules with Twigcs.

@Chi-teck
Copy link
Contributor Author

Chi-teck commented Mar 4, 2019

My understanding of this is that you should format like this

That's how we work around right now. But this kind of formatting does not look well.

@OwlyCode
Copy link
Collaborator

OwlyCode commented Mar 4, 2019

I personally got quite used to it, it saves 2 lines in vertical space. But that's pure opinion without any facts.

Twigcs is not about forcing you to do this. The tool is meant to allow you to enforce the rules you want in your project. In your case you should go with a custom Ruleset so you can set up the coding style that suits you.

@Chi-teck
Copy link
Contributor Author

Chi-teck commented Mar 4, 2019

Yes, but the rule (DelimiterSpacing) has no configuration options to change that behavior. So besides the Ruleset we will have to develop a new Rule for that.

@OwlyCode
Copy link
Collaborator

OwlyCode commented Mar 4, 2019

We can add this. I have very little available time at the moment for open source projects. If you want to help you can add this or I will do it but that will take some time.

@Chi-teck
Copy link
Contributor Author

Chi-teck commented Mar 4, 2019

I am not quite familiar with Twig lexer. So I think it ls better to leave this for you.
Thanks.

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

2 participants