-
-
Notifications
You must be signed in to change notification settings - Fork 166
Allow sorting classes inside function calls in Twig templates #358
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
base: main
Are you sure you want to change the base?
Conversation
…e formatting consistency - Added support for `attributes.addClass()` in Drupal Twig templates. - Updated test cases to validate new `addClass` functionality. - Improved formatting consistency in TypeScript code for better readability. - Added .DS_Store to .gitignore to prevent unnecessary files from being tracked.
@thecrypticace Thanks for the code revisions. Any plans to release this feature in the near future? |
I think we could also consider support for https://www.drupal.org/docs/8/theming-drupal-8/using-attributes-in-templates#s-attributesremoveclass |
I still have to do some thinking about the implementation as there's a disconnect between how call expressions are walked in JSX and Twig. That might be fine to have a slight difference in behavior but not sure.
This implementation supports any function call. I made it generic. Our plugin already has affordances for sorting in function calls via the See the updated tests. |
Support for
prettier-plugin-tailwindcss-drupal
Description
This PR adds support for the
prettier-plugin-tailwindcss-drupal
by including it in the plugin's supported file types and processors.The Drupal-specific plugin extends the sorting logic to match Tailwind conventions commonly used in Drupal theme development, including handling template attributes such as
attributes
,title_attributes
orcontent_attributes
.Problem
Tailwind projects built within Drupal environments often rely on custom attributes, classes, and template structures (e.g.,
.html.twig
files).The default Tailwind Prettier plugin does not handle these files or Drupal-specific class patterns out-of-the-box.
Solution
.html.twig
and other Drupal-related file types as supported.prettier-plugin-tailwindcss-drupal
, which is built on top of the core plugin but tailored to the Drupal ecosystem.attributes.addClass()
), commonly used for dynamic class injection.Testing
.html.twig
templates with embedded Tailwind classes.npm test
to confirm plugin compatibility.