Optionally allow to split class attribute values into multiple lines#212
Optionally allow to split class attribute values into multiple lines#212thet wants to merge 2 commits into
Conversation
Split multiple class attribute values into multiple lines. Keep it single-lined, if there is only one value. And don't split Chameleon expressions.
Per default class attributes are not split into multiple lines. That's what most tools do and most people would expect. To split class attributes into multiple lines use the `--split-class` option on the CLI.
There was a problem hiding this comment.
This will for the first time introduce a flag that controls how zpretty formats the file.
I do not think we should add it.
Either we go for always having class names split one per line or we never do that.
For me it is fine to have classes one per line, but I think this should be discussed with the community, also because it will cause a lot of broken dependabot PRs.
If we go for such a bold move, it might also be interesting to change that only if the line length is longer than a given amount of characters (that would even make the formatter fully compliant with the ZCML style guide, see #12).
But before deciding something on this I would like to hear more opinions.
|
My 2 cents here:
My main expectation from using a linter is to easy my life, and when it comes to commits means making diffs as small as possible, That together with the multiline, could be used to group within the same line, the classes that have the same prefix (again, if they don't go over the 80 characters threshold). So this PR looks like a good step in the right direction to me if we apply |
I also agree that we should either go all in or not 👍
Yeah, that would be nice also to solve #12 as already mentioned
I think sorting/grouping might lead to undesired effects, see:
It might be interesting to split the classes by new line so that we can have something like: formatted as: Which would be very similar to what happens with a Let me know, I am very open to include a similar feature. |
|
That looks better indeed 👍🏾 As for sorting/grouping, at work we are using BEM methodology for CSS, so our classes look like: So keeping the But as not everyone is using that I'm fine having to either add it ourselves on a fork of it, or giving up on the idea 😅 Could I ask for a function/method that allows a potential patch be made easy by isolating the parsing of the classes before/after the split? Then we could implement our logic there without having to force it upstream 😄 |
|
Me and Hannes are going to mee at the Buschenschanksprint and could work on that. You are welcome to provide and example of the code should be, either in a comment or by providing failing tests, or by adding some classes here: https://github.com/collective/zpretty/blob/master/zpretty/tests/original/sample_pt.pt |
Multiline values for class attributes.
Split multiple class attribute values into multiple lines. Keep it
single-lined, if there is only one value. And don't split Chameleon
expressions.
Add a switch for multiline class attribute values.
Per default class attributes are not split into multiple lines. That's what
most tools do and most people would expect. To split class attributes into
multiple lines use the
--split-classoption on the CLI.