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

Formatting tagged template literals #19840

Open
cyruseuros opened this issue Jul 14, 2023 · 3 comments
Open

Formatting tagged template literals #19840

cyruseuros opened this issue Jul 14, 2023 · 3 comments
Labels
deno fmt Related to the "deno fmt" subcommand or dprint feat new feature (which has been agreed to/accepted)

Comments

@cyruseuros
Copy link

A lot of modern frontend (often web-component-based) frameworks make use of JS/TS tagged template literals for inline html/css. To the point where most editors (and even GitHub) recognize it and apply syntax highlighting:

html`<div>foo</div>`.css`:root { --primary: #000 }`

Would it be possible for deno fmt to take these into consideration just like Prettier does and as Deno itself does for markdown code snippets?

@bartlomieju bartlomieju added the deno fmt Related to the "deno fmt" subcommand or dprint label Jul 17, 2023
@bartlomieju
Copy link
Member

@dsherret any thoughts here?

@bartlomieju bartlomieju added the feat new feature (which has been agreed to/accepted) label Dec 9, 2024
@bartlomieju
Copy link
Member

This is being worked on in dprint/dprint-plugin-typescript#683.

@mb21
Copy link

mb21 commented Dec 11, 2024

@bartlomieju great news! In case you need a semi-complex example that's currently handled quite badly by deno fmt:

export const Layout = (props: Props) => html`
  <html>
    <body>
      ${props.title.endsWith("example")
        ? html`
            <a href="/">Reactive Mastro examples</a>
            <h1>${props.title}</h1>
            `
        : ""}
      <main>${props.children}</main>
    </body>
  </html>
  `;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno fmt Related to the "deno fmt" subcommand or dprint feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

3 participants