Skip to content

Don't print Angular attribute values that are single template/string literals, on new lines#18378

Merged
fisker merged 9 commits intoprettier:mainfrom
ravindUwU:issue-17729-angular-template-literal-hugs
Dec 9, 2025
Merged

Don't print Angular attribute values that are single template/string literals, on new lines#18378
fisker merged 9 commits intoprettier:mainfrom
ravindUwU:issue-17729-angular-template-literal-hugs

Conversation

@ravindUwU
Copy link
Contributor

@ravindUwU ravindUwU commented Nov 30, 2025

Description

This PR modifies shouldHugJsExpression of the HTML formatting logic so that Angular directive values that are single template/string literals are "hugged", and NOT formatted on their own line.

Fixes #17729.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

@netlify
Copy link

netlify bot commented Nov 30, 2025

Deploy Preview for prettier ready!

Name Link
🔨 Latest commit a7bd4da
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6937bd576faec50008999153
😎 Deploy Preview https://deploy-preview-18378--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ravindUwU ravindUwU marked this pull request as ready for review November 30, 2025 09:07
@ravindUwU ravindUwU force-pushed the issue-17729-angular-template-literal-hugs branch from 245418c to 1bfb315 Compare November 30, 2025 10:37
@ravindUwU ravindUwU changed the title Don't print Angular attribute values that are single template/tagged template/string literals, on new lines Don't print Angular attribute values that are single template/string literals, on new lines Nov 30, 2025
@ravindUwU ravindUwU force-pushed the issue-17729-angular-template-literal-hugs branch from 4fb157e to d2c9e20 Compare November 30, 2025 11:32
Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

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

Thank you!

@fisker fisker added this to the 3.8 milestone Nov 30, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 30, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/plugin-hermes@18378.tgz
yarn add https://pkg.pr.new/@prettier/plugin-oxc@18378.tgz
yarn add https://pkg.pr.new/prettier@18378.tgz

commit: a7bd4da

@fisker fisker merged commit f2ce657 into prettier:main Dec 9, 2025
35 checks passed
@fisker fisker modified the milestones: 3.9, 3.8 Jan 14, 2026
fisker added a commit that referenced this pull request Jan 14, 2026
…literals, on new lines (#18378)

Co-authored-by: fisker <lionkay@gmail.com>
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.

Preserve formatting of multi-line template literal values assigned to Angular attributes? Since 3.6

2 participants