Skip to content

fix: allow expression to be used as key-value pair or block in embedded css #712

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

Merged

Conversation

kt3k
Copy link
Contributor

@kt3k kt3k commented May 19, 2025

We currently use the pattern dpr1nt_00_d (number part incremented by occurrence) for placeholder for expression occurrence in template literals. This causes a problem when the expression used as key-value pair (or block) replacement in embedded CSS template literals. This happens because dpr1nt_00_d only works as key or value of property in CSS, and it doesn't work as key-value pair replacement.

This PR tries to fix it by using the pattern @dpr1nt_00_d in CSS template literals, and changing the css syntax to LESS. In LESS @var can be both values and mixins (mixin works as replacement of key-value pair).

Note: prettier uses @prettier-placeholder-0-id for placeholder. ref https://github.com/prettier/prettier/blob/d75b21f4b6e86f5751738f51083d685bb4a97965/src/language-js/embed/css.js#L18-L20

related denoland/deno#29337

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dsherret dsherret merged commit 35eb1df into dprint:main May 21, 2025
3 checks passed
@kt3k kt3k deleted the fix-embedded-css-allow-key-value-pair-placeholder branch May 22, 2025 05:43
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.

2 participants