Open ioleo opened 9 years ago
:+1:
After some discussions, we emit the idea about using PHP CS-Fixer (on dev environment only).
This will effectively handle PHP files... but not Twig ones... Does any one know a Java or PHP script or anything else to auto-format Twig files?
Actually auto-formatting twig templates... may be impossible.
How does the formating tool know if:
{% block abc %}I am
broken into
three lines{% endblock %}
is on purpose (part of the design) or a byproduct of lacking whitespace control (and should be fixed)?
Actually some IDE do it... so it should be possible... No?
I've done a little research. I could not find any TWIG "format" or "prettify" library. We'd have to write our own.
The code rendered from templates is hard to control, due to lack of proper whitespace control in Twig.
I've pushed a PR which addresses that issue in Twig. If it is merged, we should review the templates and use the new whitespace control operator where needed.