-
Notifications
You must be signed in to change notification settings - Fork 62
feat: support formatting of languages embedded in tagged template literals (Rust API Only) #701
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
continued from #683
towards denoland/deno#26880
Updates from the above:
css
,styled.foo
, andstyled(Foo)
tags for css,html
tag for html,sql
tag for sql.dprint_placeholder_N_id
for 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: