Closed urbantrout closed 4 years ago
Hey Harald, thanks for the suggestion. The problem I see is that part of the coding standards might be at odds with what Prettier is all about. Let's look at a real-world example where a filter expression won't fit on one line:
<p class="alert__message">
{{
'results_for'
| translate({ searchedTerm: '<mark class="highlight-search-term">' ~ semKeyword ~ '</mark>' })
| raw
}}
</p>
Having no whitespace whatsoever around the |
operator would force Prettier to put it all on one line, which goes against the purpose of even using Prettier.
What I can try to do is to go without any spaces as long as the filter expression fits on one line, and insert breaks if it doesn't.
Would you prefer having line breaks, but no spaces after the |
operators, like this?
<p class="alert__message">
{{
'results_for'
|translate({ searchedTerm: '<mark class="highlight-search-term">' ~ semKeyword ~ '</mark>' })
|raw
}}
</p>
At some point, I need to insert the points where the code can break (since I assume you know German: "Sollbruchstellen"), and these points are usually around operators.
What do you think?
P.S.: I find the coding standard a little inconsistent, also. Why shouldn't we have spaces around |
, but around all other operators like +
, -
, ~
, etc.?
Hello @urbantrout, I just published version 0.2.0
, which improves adherence to the Twig coding standards. When long filter expressions don't fit in the line, there might still be breaks, though.
Can you give it a try?
Closing this issue for now, as I consider it resolved. Please tell me if you think otherwise.
See: https://twig.symfony.com/doc/2.x/coding_standards.html
Specifically: