feat: support formatting of languages embedded in tagged template literals (Rust API Only)#701
Conversation
cf05f55 to
b527e1f
Compare
|
@dsherret I think now this is ready for review. PTAL when you have time |
|
@kt3k can you please open a PR to Deno with a Cargo patch pointing to this PR to test it end-to-end? |
|
Sure! |
|
Opened denoland/deno#29014 |
dsherret
left a comment
There was a problem hiding this comment.
LGTM! Note to others: this is currently just for the Rust API. Support for Wasm will come later.
This commit adds the formatting of CSS, HTML, and SQL which are embedded in
Tagged Template Literal strings. The embedded languages are detected by
the tag name of the literal.
```ts
// triggers CSS formatting
const Div = styled.div`
margin: 5px;
padding: ${padding}px;
`;
// triggers HTML formatting
document.body.innerHTML = html`
<main>
<h1>Hello ${name}!<h1>
</main>
`;
// triggers SQL formatting when `--unstable-sql` passed
const query = sql`
SELECT
${table}.${field}
FROM
${table};
`
```
See dprint/dprint-plugin-typescript#701 for more
details
does it mean this can be closed as resolved now? if so, do I need to configure anything to start using it? Thanks! |
I'm encountering the same issue. Was this resolved? If there's a specific configuration needed to fix this, please let me know. |
continued from #683
towards denoland/deno#26880
Updates from the above:
css,styled.foo, andstyled(Foo)tags for css,htmltag for html,sqltag for sql.dprint_placeholder_N_idfor the placeholders between quasis (The identifier is inspired by prettier implementation css html)malva(css),markup_fmt(html), anddprint-plugin-sql(sql) for testing.(Didn't add support of styled-jsx (
<style jsx>) as it seems less popular these days).remaining tasks:
references: