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

[#33] Enable Prettier for Twig & Tailwind formatting #58

Draft
wants to merge 3 commits into
base: 5.x
Choose a base branch
from

Conversation

joshuapease
Copy link
Contributor

@joshuapease joshuapease commented Nov 11, 2024

An experimental branch to test Prettier for Twig & Tailwind.

Checkout the branch and run ddev npm run format to see it in action.

The official TW prettier plugin supports @zackad/prettier-plugin-twig (even though it doesn't say so in the readme)

Twig Formatting

It's very "prettier" in its opinion. It introduces a lot of extra line breaks to keep line lengths short.

It doesn't look like our typical way of writing Twig, but it's not necessarily a bad thing.

CleanShot 2025-02-25 at 09 22 17@2x

CleanShot 2025-02-25 at 09 22 32@2x

CleanShot 2025-02-25 at 09 22 51@2x

CleanShot 2025-02-25 at 09 23 19@2x

CleanShot 2025-02-25 at 09 24 13@2x

CleanShot 2025-02-25 at 09 25 34@2x

Class Sorting

Below are a few common ways we write Tailwind CSS in our Twig templates.

Prettier catches most things that are within a normal class attribute. However, it misses when we use attr with class: 'bg-red-50.

There might be some config options that could improve things a bit.

CleanShot 2025-02-25 at 09 19 22@2x

Prettier Errors

Default values in Macros seems to error (even though this is Basic Twig Stuff).

CleanShot 2025-02-25 at 09 26 15@2x

Base automatically changed from jp/51-header-and-footer to jp/45-page-blocks-and-sections December 18, 2024 13:52
Base automatically changed from jp/45-page-blocks-and-sections to jp/44-base-ui-elements December 18, 2024 13:53
Base automatically changed from jp/44-base-ui-elements to 5.x December 18, 2024 13:54
@joshuapease joshuapease force-pushed the 5.x branch 2 times, most recently from ed9b9f8 to 6f1bd23 Compare January 17, 2025 14:50
TODO: Still needc to sort out how to get TW to work with .twig extension
@joshuapease joshuapease force-pushed the jp/33-twig-tailwind-prettier branch from d081320 to 2bd9ddb Compare February 25, 2025 16:27
@joshuapease joshuapease changed the title [#33] twig tailwind prettier [#33] Enable Prettier for Twig & Tailwind formatting Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant