In my Javascript code I have many template literals that contain HTML code. These blocks are correctly highlighted via es6-string-html. However, they are not formatted automatically, which means the following block will be left as is:
let html = `
<div class="wrapper">
<div>Hello, world!
</div>
</div>
`;
How can I enable auto-formatting for these strings as well?
When Prettier detects a tagged template in JavaScript with a tag named html, it will format it. You can read more about this here and for highlighted you can use what you suggested es6-string-html
/**
* html wrapper is needed for prettier formatting
*/
const html = String.raw;
const template = html`
<div>
<p>hello world</p>
<p>hello world</p>
</div>
`;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With